update new sdk

This commit is contained in:
August 2020-07-15 19:27:51 +08:00
parent f33907443a
commit 744c72c133
1643 changed files with 83006 additions and 28021 deletions

View file

@ -1034,14 +1034,14 @@ CONFIG_BT_DEBUGFS=y
# Bluetooth device drivers
#
# CONFIG_BT_HCIBTUSB is not set
CONFIG_BT_RTKBTUSB=y
# CONFIG_BT_RTKBTUSB is not set
# CONFIG_BT_HCIBTSDIO is not set
CONFIG_BT_HCIUART=y
CONFIG_BT_HCIUART_H4=y
# CONFIG_BT_HCIUART_BCSP is not set
# CONFIG_BT_HCIUART_ATH3K is not set
# CONFIG_BT_HCIUART_LL is not set
# CONFIG_BT_HCIUART_3WIRE is not set
CONFIG_BT_HCIUART_3WIRE=y
# CONFIG_BT_HCIUART_INTEL is not set
# CONFIG_BT_HCIUART_BCM is not set
# CONFIG_BT_HCIUART_QCA is not set

13
lichee/linux-4.9/arch/arm64/include/asm/assembler.h Normal file → Executable file
View file

@ -429,17 +429,4 @@ alternative_endif
mrs \rd, sp_el0
.endm
/*
* Errata workaround post TTBR0_EL1 update.
*/
.macro post_ttbr0_update_workaround
#ifdef CONFIG_CAVIUM_ERRATUM_27456
alternative_if ARM64_WORKAROUND_CAVIUM_27456
ic iallu
dsb nsh
isb
alternative_else_nop_endif
#endif
.endm
#endif /* __ASM_ASSEMBLER_H */

12
lichee/linux-4.9/arch/arm64/include/asm/efi.h Normal file → Executable file
View file

@ -82,12 +82,14 @@ static inline void efi_set_pgd(struct mm_struct *mm)
if (mm != current->active_mm) {
/*
* Update the current thread's saved ttbr0 since it is
* restored as part of a return from exception. Set
* the hardware TTBR0_EL1 using cpu_switch_mm()
* directly to enable potential errata workarounds.
* restored as part of a return from exception. Enable
* access to the valid TTBR0_EL1 and invoke the errata
* workaround directly since there is no return from
* exception when invoking the EFI run-time services.
*/
update_saved_ttbr0(current, mm);
cpu_switch_mm(mm->pgd, mm);
uaccess_ttbr0_enable();
post_ttbr_update_workaround();
} else {
/*
* Defer the switch to the current thread's TTBR0_EL1
@ -95,7 +97,7 @@ static inline void efi_set_pgd(struct mm_struct *mm)
* thread's saved ttbr0 corresponding to its active_mm
* (if different from init_mm).
*/
cpu_set_reserved_ttbr0();
uaccess_ttbr0_disable();
if (current->active_mm != &init_mm)
update_saved_ttbr0(current, current->active_mm);
}

7
lichee/linux-4.9/arch/arm64/include/asm/mmu_context.h Normal file → Executable file
View file

@ -169,9 +169,10 @@ static inline void update_saved_ttbr0(struct task_struct *tsk,
struct mm_struct *mm)
{
if (system_uses_ttbr0_pan()) {
u64 ttbr;
BUG_ON(mm->pgd == swapper_pg_dir);
task_thread_info(tsk)->ttbr0 =
virt_to_phys(mm->pgd) | ASID(mm) << 48;
ttbr = virt_to_phys(mm->pgd) | ASID(mm) << 48;
WRITE_ONCE(task_thread_info(tsk)->ttbr0, ttbr);
}
}
#else
@ -220,4 +221,6 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
void verify_cpu_asid_bits(void);
void post_ttbr_update_workaround(void);
#endif

45
lichee/linux-4.9/arch/arm64/include/asm/uaccess.h Normal file → Executable file
View file

@ -130,25 +130,41 @@ static inline void set_fs(mm_segment_t fs)
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
static inline void __uaccess_ttbr0_disable(void)
{
unsigned long ttbr;
unsigned long flags, ttbr;
local_irq_save(flags);
ttbr = read_sysreg(ttbr1_el1);
ttbr &= ~(UL(0xffff) << 48);
/* reserved_ttbr0 placed at the end of swapper_pg_dir */
ttbr = read_sysreg(ttbr1_el1) + SWAPPER_DIR_SIZE;
write_sysreg(ttbr, ttbr0_el1);
write_sysreg(ttbr + SWAPPER_DIR_SIZE, ttbr0_el1);
isb();
/* Set reserved ASID */
write_sysreg(ttbr, ttbr1_el1);
isb();
local_irq_restore(flags);
}
static inline void __uaccess_ttbr0_enable(void)
{
unsigned long flags;
unsigned long flags, ttbr0, ttbr1;
/*
* Disable interrupts to avoid preemption between reading the 'ttbr0'
* variable and the MSR. A context switch could trigger an ASID
* roll-over and an update of 'ttbr0'.
*/
* Disable interrupts to avoid preemption between reading the 'ttbr0'
* variable and the MSR. A context switch could trigger an ASID
* roll-over and an update of 'ttbr0'.
*/
local_irq_save(flags);
write_sysreg(current_thread_info()->ttbr0, ttbr0_el1);
ttbr0 = READ_ONCE(current_thread_info()->ttbr0);
/* Restore active ASID */
ttbr1 = read_sysreg(ttbr1_el1);
ttbr1 &= ~(UL(0xffff) << 48); /* safety measure */
ttbr1 |= ttbr0 & (UL(0xffff) << 48);
write_sysreg(ttbr1, ttbr1_el1);
isb();
/* Restore user page table */
write_sysreg(ttbr0, ttbr0_el1);
isb();
local_irq_restore(flags);
}
@ -435,6 +451,7 @@ extern __must_check long strnlen_user(const char __user *str, long n);
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
.macro __uaccess_ttbr0_disable, tmp1
mrs \tmp1, ttbr1_el1 // swapper_pg_dir
bic \tmp1, \tmp1, #(0xffff) << 48
add \tmp1, \tmp1, #SWAPPER_DIR_SIZE // reserved_ttbr0 at the end of swapper_pg_dir
msr ttbr0_el1, \tmp1 // set reserved TTBR0_EL1
isb
@ -447,9 +464,11 @@ extern __must_check long strnlen_user(const char __user *str, long n);
isb
.endm
.macro uaccess_ttbr0_disable, tmp1
.macro uaccess_ttbr0_disable, tmp1, tmp2
alternative_if_not ARM64_HAS_PAN
save_and_disable_irq \tmp2 // avoid preemption
__uaccess_ttbr0_disable \tmp1
restore_irq \tmp2
alternative_else_nop_endif
.endm
@ -461,7 +480,7 @@ alternative_if_not ARM64_HAS_PAN
alternative_else_nop_endif
.endm
#else
.macro uaccess_ttbr0_disable, tmp1
.macro uaccess_ttbr0_disable, tmp1, tmp2
.endm
.macro uaccess_ttbr0_enable, tmp1, tmp2
@ -471,8 +490,8 @@ alternative_else_nop_endif
/*
* These macros are no-ops when UAO is present.
*/
.macro uaccess_disable_not_uao, tmp1
uaccess_ttbr0_disable \tmp1
.macro uaccess_disable_not_uao, tmp1, tmp2
uaccess_ttbr0_disable \tmp1, \tmp2
alternative_if ARM64_ALT_PAN_NOT_UAO
SET_PSTATE_PAN(1)
alternative_else_nop_endif

4
lichee/linux-4.9/arch/arm64/kernel/entry.S Normal file → Executable file
View file

@ -128,7 +128,7 @@ alternative_else_nop_endif
.if \el != 0
mrs x21, ttbr0_el1
tst x21, #0xffff << 48 // Check for the reserved ASID
tst x21, #(0xffff) << 48 // Check for the reserved ASID
orr x23, x23, #PSR_PAN_BIT // Set the emulated PAN in the saved SPSR
b.eq 1f // TTBR0 access already disabled
and x23, x23, #~PSR_PAN_BIT // Clear the emulated PAN in the saved SPSR
@ -200,7 +200,7 @@ alternative_else_nop_endif
* Cavium erratum 27456 (broadcast TLBI instructions may cause I-cache
* corruption).
*/
post_ttbr0_update_workaround
bl post_ttbr_update_workaround
.endif
1:
.if \el != 0

2
lichee/linux-4.9/arch/arm64/lib/clear_user.S Normal file → Executable file
View file

@ -50,7 +50,7 @@ uao_user_alternative 9f, strh, sttrh, wzr, x0, 2
b.mi 5f
uao_user_alternative 9f, strb, sttrb, wzr, x0, 0
5: mov x0, #0
uaccess_disable_not_uao x2
uaccess_disable_not_uao x2, x3
ret
ENDPROC(__clear_user)

2
lichee/linux-4.9/arch/arm64/lib/copy_from_user.S Normal file → Executable file
View file

@ -67,7 +67,7 @@ ENTRY(__arch_copy_from_user)
uaccess_enable_not_uao x3, x4
add end, x0, x2
#include "copy_template.S"
uaccess_disable_not_uao x3
uaccess_disable_not_uao x3, x4
mov x0, #0 // Nothing to copy
ret
ENDPROC(__arch_copy_from_user)

2
lichee/linux-4.9/arch/arm64/lib/copy_in_user.S Normal file → Executable file
View file

@ -68,7 +68,7 @@ ENTRY(__copy_in_user)
uaccess_enable_not_uao x3, x4
add end, x0, x2
#include "copy_template.S"
uaccess_disable_not_uao x3
uaccess_disable_not_uao x3, x4
mov x0, #0
ret
ENDPROC(__copy_in_user)

2
lichee/linux-4.9/arch/arm64/lib/copy_to_user.S Normal file → Executable file
View file

@ -66,7 +66,7 @@ ENTRY(__arch_copy_to_user)
uaccess_enable_not_uao x3, x4
add end, x0, x2
#include "copy_template.S"
uaccess_disable_not_uao x3
uaccess_disable_not_uao x3, x4
mov x0, #0
ret
ENDPROC(__arch_copy_to_user)

4
lichee/linux-4.9/arch/arm64/mm/cache.S Normal file → Executable file
View file

@ -72,7 +72,7 @@ USER(9f, ic ivau, x4 ) // invalidate I line PoU
isb
mov x0, #0
1:
uaccess_ttbr0_disable x1
uaccess_ttbr0_disable x1, x2
ret
9:
mov x0, #-EFAULT
@ -214,6 +214,6 @@ ENDPIPROC(__dma_unmap_area)
ENTRY(__dma_flush_range)
uaccess_ttbr0_enable x2, x3
dcache_by_line_op civac, sy, x0, x1, x2, x3
uaccess_ttbr0_disable x1
uaccess_ttbr0_disable x1, x2
ret
ENDPIPROC(__dma_flush_range)

9
lichee/linux-4.9/arch/arm64/mm/context.c Normal file → Executable file
View file

@ -229,6 +229,15 @@ switch_mm_fastpath:
cpu_switch_mm(mm->pgd, mm);
}
/* Errata workaround post TTBRx_EL1 update. */
asmlinkage void post_ttbr_update_workaround(void)
{
asm(ALTERNATIVE("nop; nop; nop",
"ic iallu; dsb nsh; isb",
ARM64_WORKAROUND_CAVIUM_27456,
CONFIG_CAVIUM_ERRATUM_27456));
}
static int asids_init(void)
{
asid_bits = get_cpu_asid_bits();

6
lichee/linux-4.9/arch/arm64/mm/proc.S Normal file → Executable file
View file

@ -133,11 +133,13 @@ ENDPROC(cpu_do_resume)
*/
ENTRY(cpu_do_switch_mm)
mmid x1, x1 // get mm->context.id
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
bfi x0, x1, #48, #16 // set the ASID field in TTBR0
#endif
bfi x0, x1, #48, #16 // set the ASID
msr ttbr0_el1, x0 // set TTBR0
isb
post_ttbr0_update_workaround
ret
b post_ttbr_update_workaround // Back to C code...
ENDPROC(cpu_do_switch_mm)
.pushsection ".idmap.text", "ax"

2
lichee/linux-4.9/arch/arm64/xen/hypercall.S Normal file → Executable file
View file

@ -106,6 +106,6 @@ ENTRY(privcmd_call)
/*
* Disable userspace access from kernel once the hyp call completed.
*/
uaccess_ttbr0_disable x6
uaccess_ttbr0_disable x6, x7
ret
ENDPROC(privcmd_call);

4
lichee/linux-4.9/block/blk-cgroup.c Normal file → Executable file
View file

@ -1078,10 +1078,8 @@ int blkcg_init_queue(struct request_queue *q)
if (preloaded)
radix_tree_preload_end();
if (IS_ERR(blkg)) {
blkg_free(new_blkg);
if (IS_ERR(blkg))
return PTR_ERR(blkg);
}
q->root_blkg = blkg;
q->root_rl.blkg = blkg;

6
lichee/linux-4.9/crypto/hmac.c Normal file → Executable file
View file

@ -194,11 +194,15 @@ static int hmac_create(struct crypto_template *tmpl, struct rtattr **tb)
salg = shash_attr_alg(tb[1], 0, 0);
if (IS_ERR(salg))
return PTR_ERR(salg);
alg = &salg->base;
/* The underlying hash algorithm must be unkeyed */
err = -EINVAL;
if (crypto_shash_alg_has_setkey(salg))
goto out_put_alg;
ds = salg->digestsize;
ss = salg->statesize;
alg = &salg->base;
if (ds > alg->cra_blocksize ||
ss < alg->cra_blocksize)
goto out_put_alg;

19
lichee/linux-4.9/crypto/pcrypt.c Normal file → Executable file
View file

@ -254,6 +254,14 @@ static void pcrypt_aead_exit_tfm(struct crypto_aead *tfm)
crypto_free_aead(ctx->child);
}
static void pcrypt_free(struct aead_instance *inst)
{
struct pcrypt_instance_ctx *ctx = aead_instance_ctx(inst);
crypto_drop_aead(&ctx->spawn);
kfree(inst);
}
static int pcrypt_init_instance(struct crypto_instance *inst,
struct crypto_alg *alg)
{
@ -319,6 +327,8 @@ static int pcrypt_create_aead(struct crypto_template *tmpl, struct rtattr **tb,
inst->alg.encrypt = pcrypt_aead_encrypt;
inst->alg.decrypt = pcrypt_aead_decrypt;
inst->free = pcrypt_free;
err = aead_register_instance(tmpl, inst);
if (err)
goto out_drop_aead;
@ -349,14 +359,6 @@ static int pcrypt_create(struct crypto_template *tmpl, struct rtattr **tb)
return -EINVAL;
}
static void pcrypt_free(struct crypto_instance *inst)
{
struct pcrypt_instance_ctx *ctx = crypto_instance_ctx(inst);
crypto_drop_aead(&ctx->spawn);
kfree(inst);
}
static int pcrypt_cpumask_change_notify(struct notifier_block *self,
unsigned long val, void *data)
{
@ -469,7 +471,6 @@ static void pcrypt_fini_padata(struct padata_pcrypt *pcrypt)
static struct crypto_template pcrypt_tmpl = {
.name = "pcrypt",
.create = pcrypt_create,
.free = pcrypt_free,
.module = THIS_MODULE,
};

5
lichee/linux-4.9/crypto/shash.c Normal file → Executable file
View file

@ -24,11 +24,12 @@
static const struct crypto_type crypto_shash_type;
static int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
unsigned int keylen)
int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
unsigned int keylen)
{
return -ENOSYS;
}
EXPORT_SYMBOL_GPL(shash_no_setkey);
static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
unsigned int keylen)

3
lichee/linux-4.9/drivers/amba/bus.c Normal file → Executable file
View file

@ -83,7 +83,8 @@ static ssize_t driver_override_store(struct device *_dev,
struct amba_device *dev = to_amba_device(_dev);
char *driver_override, *old = dev->driver_override, *cp;
if (count > PATH_MAX)
/* We need to keep extra room for a newline */
if (count > (PAGE_SIZE) - 1)
return -EINVAL;
driver_override = kstrndup(buf, count, GFP_KERNEL);

2
lichee/linux-4.9/drivers/base/firmware_class.c Normal file → Executable file
View file

@ -291,7 +291,7 @@ static void fw_free_buf(struct firmware_buf *buf)
static char fw_path_para[256];
static const char * const fw_path[] = {
fw_path_para,
"/vendor/etc/firmware/",
"/vendor/etc/firmware/", /* bpi, for rtk bt firmware load */
"/lib/firmware/updates/" UTS_RELEASE,
"/lib/firmware/updates",
"/lib/firmware/" UTS_RELEASE,

View file

@ -96,6 +96,11 @@ int sunxi_smc_writel(u32 value, phys_addr_t addr)
}
EXPORT_SYMBOL_GPL(sunxi_smc_writel);
int sunxi_smc_probe_secure(void)
{
return invoke_smc_fn(ARM_SVC_EFUSE_PROBE_SECURE_ENABLE, 0, 0, 0);
}
int sunxi_smc_copy_arisc_paras(phys_addr_t dest, phys_addr_t src, u32 len)
{
struct arm_smccc_res res;
@ -113,11 +118,11 @@ phys_addr_t sunxi_smc_get_teeaddr_paras(phys_addr_t resumeaddr)
}
/*optee smc*/
#define ARM_SMCCC_STD_CALL 0
#define ARM_SMCCC_FAST_CALL 1
#define ARM_SMCCC_FAST_CALL 1U
#define ARM_SMCCC_TYPE_SHIFT 31
#define ARM_SMCCC_SMC_32 0
#define ARM_SMCCC_SMC_64 1
#define ARM_SMCCC_SMC_64 1U
#define ARM_SMCCC_CALL_CONV_SHIFT 30
#define ARM_SMCCC_OWNER_MASK 0x3F

0
lichee/linux-4.9/drivers/clk/ux500/Makefile Normal file → Executable file
View file

0
lichee/linux-4.9/drivers/clk/ux500/abx500-clk.c Normal file → Executable file
View file

0
lichee/linux-4.9/drivers/clk/ux500/clk-prcc.c Normal file → Executable file
View file

0
lichee/linux-4.9/drivers/clk/ux500/clk-prcmu.c Normal file → Executable file
View file

0
lichee/linux-4.9/drivers/clk/ux500/clk-sysctrl.c Normal file → Executable file
View file

0
lichee/linux-4.9/drivers/clk/ux500/clk.h Normal file → Executable file
View file

0
lichee/linux-4.9/drivers/clk/ux500/u8500_of_clk.c Normal file → Executable file
View file

0
lichee/linux-4.9/drivers/clk/ux500/u8540_clk.c Normal file → Executable file
View file

0
lichee/linux-4.9/drivers/clk/ux500/u9540_clk.c Normal file → Executable file
View file

9
lichee/linux-4.9/drivers/gpu/drm/udl/udl_fb.c Normal file → Executable file
View file

@ -158,10 +158,15 @@ static int udl_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
{
unsigned long start = vma->vm_start;
unsigned long size = vma->vm_end - vma->vm_start;
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
unsigned long offset;
unsigned long page, pos;
if (offset + size > info->fix.smem_len)
if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
return -EINVAL;
offset = vma->vm_pgoff << PAGE_SHIFT;
if (offset > info->fix.smem_len || size > info->fix.smem_len - offset)
return -EINVAL;
pos = (unsigned long)info->fix.smem_start + offset;

40
lichee/linux-4.9/drivers/input/misc/stk3x1x.c Normal file → Executable file
View file

@ -81,14 +81,14 @@
/* Driver Settings */
#define CONFIG_STK_PS_ALS_USE_CHANGE_THRESHOLD
#ifdef CONFIG_STK_PS_ALS_USE_CHANGE_THRESHOLD
#define STK_ALS_CHANGE_THD 20 /* The threshold to trigger ALS interrupt, unit: lux */
#define STK_ALS_CHANGE_THD 0 /* The threshold to trigger ALS interrupt, unit: lux */
#endif
#define STK_INT_PS_MODE 1 /* 1, 2, or 3 */
#define STK_POLL_PS
/* ALS interrupt is valid only when STK_INT_PS_MODE = 1 or 4*/
#define STK_POLL_ALS
#define STK_TUNE0
/* #define STK_TUNE0 */
/*#define STK_DEBUG_PRINTF
#define STK_ALS_FIR
#define STK_IRS
@ -2298,18 +2298,16 @@ static void stk_ps_poll_work_func(struct work_struct *work)
return;
near_far_state = (org_flag_reg & STK_FLG_NF_MASK) ? 1 : 0;
reading = stk3x1x_get_ps_reading(ps_data);
if (ps_data->ps_distance_last != near_far_state) {
ps_data->ps_distance_last = near_far_state;
dprintk(DEBUG_REPORT_ALS_DATA, "proximity data = %d\n", near_far_state);
input_report_abs(ps_data->ps_input_dev, ABS_DISTANCE, near_far_state);
input_sync(ps_data->ps_input_dev);
/*support wake lock for ps*/
/*wake_lock_timeout(&ps_data->ps_wakelock, 3*HZ);*/
ps_data->ps_distance_last = near_far_state;
dprintk(DEBUG_REPORT_ALS_DATA, "proximity data = %d\n", near_far_state);
input_report_abs(ps_data->ps_input_dev, ABS_DISTANCE, near_far_state);
input_sync(ps_data->ps_input_dev);
/*support wake lock for ps*/
/*wake_lock_timeout(&ps_data->ps_wakelock, 3*HZ);*/
#ifdef STK_DEBUG_PRINTF
printk(KERN_INFO "%s: ps input event %d cm, ps code = %d\n", __func__, near_far_state, reading);
#endif
}
ret = stk3x1x_set_flag(ps_data, org_flag_reg, disable_flag);
if (ret < 0)
goto err_i2c_rw;
@ -2614,7 +2612,9 @@ static int stk3x1x_suspend(struct device *dev, pm_message_t mesg)
mutex_unlock(&ps_data->io_lock);
if (ls_sensor_info.sensor_power_ldo != NULL) {
regulator_disable(ls_sensor_info.sensor_power_ldo);
err = regulator_disable(ls_sensor_info.sensor_power_ldo);
if (err)
printk("stk power down failed\n");
}
return 0;
@ -2627,8 +2627,10 @@ static int stk3x1x_resume(struct device *dev)
uint8_t disable_flag = 0;
uint8_t org_flag_reg;
int32_t ret;
int err;
int32_t near_far_state;
uint32_t reading;
struct stk3x1x_data *ps_data;
/*ended by guoying*/
#if 0
if (NORMAL_STANDBY == standby_type) {
@ -2644,11 +2646,12 @@ static int stk3x1x_resume(struct device *dev)
return 0;
#endif
if (ls_sensor_info.sensor_power_ldo != NULL) {
regulator_enable(ls_sensor_info.sensor_power_ldo);
err = regulator_enable(ls_sensor_info.sensor_power_ldo);
if (err)
printk("stk power on failed\n");
msleep(100);
}
struct stk3x1x_data *ps_data = i2c_get_clientdata(client);
int err;
ps_data = i2c_get_clientdata(client);
#ifndef STK_POLL_PS
/*struct i2c_client *client = to_i2c_client(dev);*/
#endif
@ -2838,7 +2841,6 @@ static int stk3x1x_probe(struct i2c_client *client,
#ifdef STK_POLL_PS
wake_lock_init(&ps_data->ps_nosuspend_wl,WAKE_LOCK_SUSPEND, "stk_nosuspend_wakelock");
#endif */
if (&stk3x1x_pfdata != NULL) {
plat_data = &stk3x1x_pfdata;
ps_data->als_transmittance = plat_data->transmittance;
ps_data->int_pin = plat_data->int_pin;
@ -2846,10 +2848,6 @@ static int stk3x1x_probe(struct i2c_client *client,
printk(KERN_ERR "%s: Please set als_transmittance in platform data\n", __func__);
goto err_als_input_allocate;
}
} else {
printk(KERN_ERR "%s: no stk3x1x platform data!\n", __func__);
goto err_als_input_allocate;
}
ps_data->als_input_dev = input_allocate_device();
if (ps_data->als_input_dev == NULL) {
@ -3107,7 +3105,9 @@ static int __init stk3x1x_init(void)
}
stk_ps_driver.detect = stk_detect;
if (ls_sensor_info.sensor_power_ldo != NULL) {
regulator_enable(ls_sensor_info.sensor_power_ldo);
ret = regulator_enable(ls_sensor_info.sensor_power_ldo);
if (ret)
printk("stk power on failed\n");
msleep(500);
}
return i2c_add_driver(&stk_ps_driver);

125
lichee/linux-4.9/drivers/input/sensor/bma253/bma2x2.c Normal file → Executable file
View file

@ -30,6 +30,8 @@
#include <linux/delay.h>
#include <linux/irq.h>
#include <linux/time.h>
#include <linux/hrtimer.h>
#include <linux/ktime.h>
#ifdef CONFIG_HAS_EARLYSUSPEND
@ -1487,6 +1489,9 @@ struct bma2x2_data {
struct timer_list tap_timer;
int tap_time_period;
#endif
struct hrtimer hr_timer;
struct work_struct wq_hrtimer;
ktime_t ktime;
};
#ifdef CONFIG_HAS_EARLYSUSPEND
@ -4799,16 +4804,9 @@ static int bma2x2_read_accel_xyz(struct i2c_client *client,
return comres;
}
#ifndef CONFIG_BMA_ENABLE_NEWDATA_INT
static void bma2x2_work_func(struct work_struct *work)
static void report_sensor_data(struct bma2x2_data *bma2x2)
{
struct bma2x2_data *bma2x2 = container_of((struct delayed_work *)work,
struct bma2x2_data, work);
static uint64_t startTime;
static struct bma2x2acc acc;
unsigned long setDelay;
unsigned long delay = msecs_to_jiffies(atomic_read(&bma2x2->delay)) - 1;
bma2x2_read_accel_xyz(bma2x2->bma2x2_client, bma2x2->sensor_type, &acc);
input_report_abs(bma2x2->input, ABS_X, acc.x);
input_report_abs(bma2x2->input, ABS_Y, acc.y);
@ -4817,8 +4815,31 @@ static void bma2x2_work_func(struct work_struct *work)
mutex_lock(&bma2x2->value_mutex);
bma2x2->value = acc;
mutex_unlock(&bma2x2->value_mutex);
}
uint64_t deltaTime = get_jiffies_64() - startTime;
#ifndef CONFIG_BMA_ENABLE_NEWDATA_INT
static void bma2x2_work_func(struct work_struct *work)
{
struct bma2x2_data *bma2x2 = container_of((struct delayed_work *)work,
struct bma2x2_data, work);
static uint64_t startTime;
static struct bma2x2acc acc;
unsigned long setDelay;
uint64_t deltaTime;
unsigned long delay = msecs_to_jiffies(atomic_read(&bma2x2->delay)) - 1;
bma2x2_read_accel_xyz(bma2x2->bma2x2_client, bma2x2->sensor_type, &acc);
#if 0
input_report_abs(bma2x2->input, ABS_X, acc.x);
input_report_abs(bma2x2->input, ABS_Y, acc.y);
input_report_abs(bma2x2->input, ABS_Z, acc.z);
input_sync(bma2x2->input);
#endif
mutex_lock(&bma2x2->value_mutex);
bma2x2->value = acc;
mutex_unlock(&bma2x2->value_mutex);
deltaTime = get_jiffies_64() - startTime;
if (deltaTime > delay && deltaTime <= 2 * delay)
setDelay = 2 * delay - deltaTime;
else if (deltaTime > 2 * delay)
@ -5016,7 +5037,7 @@ static ssize_t bma2x2_chip_id_show(struct device *dev,
struct i2c_client *client = to_i2c_client(dev);
struct bma2x2_data *bma2x2 = i2c_get_clientdata(client);
return sprintf(buf, "%d\n", bma2x2->chip_id);
return sprintf(buf, "%u\n", bma2x2->chip_id);
}
@ -5051,6 +5072,8 @@ static ssize_t bma2x2_delay_store(struct device *dev,
if (data > BMA2X2_MAX_DELAY)
data = BMA2X2_MAX_DELAY;
atomic_set(&bma2x2->delay, (unsigned int) data);
pr_info("bma2x2: delay store %d\n", atomic_read(&bma2x2->delay));
bma2x2->ktime = ktime_set(0, atomic_read(&bma2x2->delay) * NSEC_PER_MSEC);
return count;
}
@ -5077,23 +5100,30 @@ static void bma2x2_set_enable(struct device *dev, int enable)
if (pre_enable == 0) {
bma2x2_set_mode(bma2x2->bma2x2_client,
BMA2X2_MODE_NORMAL, BMA_ENABLED_INPUT);
#ifndef CONFIG_BMA_ENABLE_NEWDATA_INT
#ifndef CONFIG_BMA_ENABLE_NEWDATA_INT
atomic_set(&bma2x2->enable, 1);
#if 0
queue_delayed_work(bma2x2->workqueue, &bma2x2->work,
msecs_to_jiffies(atomic_read(&bma2x2->delay)));
#endif
atomic_set(&bma2x2->enable, 1);
#else
bma2x2->ktime = ktime_set(0, atomic_read(&bma2x2->delay) * NSEC_PER_MSEC);
hrtimer_start(&bma2x2->hr_timer, bma2x2->ktime, HRTIMER_MODE_REL);
#endif
#endif
}
} else {
if (pre_enable == 1) {
bma2x2_set_mode(bma2x2->bma2x2_client,
BMA2X2_MODE_SUSPEND, BMA_ENABLED_INPUT);
#ifndef CONFIG_BMA_ENABLE_NEWDATA_INT
cancel_delayed_work_sync(&bma2x2->work);
flush_workqueue(bma2x2->workqueue);
#endif
#if 0
cancel_delayed_work_sync(&bma2x2->work);
flush_workqueue(bma2x2->workqueue);
#else
hrtimer_cancel(&bma2x2->hr_timer);
#endif
#endif
atomic_set(&bma2x2->enable, 0);
}
}
@ -6538,6 +6568,22 @@ static irqreturn_t bma2x2_irq_handler(int irq, void *handle)
}
#endif /* defined(BMA2X2_ENABLE_INT1)||defined(BMA2X2_ENABLE_INT2) */
static void wq_func_hrtimer(struct work_struct *work)
{
struct bma2x2_data *bma2x2 = container_of((struct work_struct *)work,
struct bma2x2_data, wq_hrtimer);
report_sensor_data(bma2x2);
}
static enum hrtimer_restart my_hrtimer_callback(struct hrtimer *timer)
{
struct bma2x2_data *bma2x2 = container_of((struct hrtimer *)timer,
struct bma2x2_data, hr_timer);
schedule_work(&bma2x2->wq_hrtimer);
hrtimer_forward_now(&bma2x2->hr_timer, bma2x2->ktime);
return HRTIMER_RESTART;
}
static int bma2x2_probe(struct i2c_client *client,
const struct i2c_device_id *id)
@ -6546,11 +6592,10 @@ static int bma2x2_probe(struct i2c_client *client,
struct bma2x2_data *data;
struct input_dev *dev;
struct bst_dev *dev_acc;
struct device_node *np = NULL;
int irq_number = 0;
struct gpio_config config;
#if defined(BMA2X2_ENABLE_INT1) || defined(BMA2X2_ENABLE_INT2)
struct device_node *np = NULL;
int irq_number;
struct gpio_config config;
struct bosch_sensor_specific *pdata;
#endif
@ -6848,6 +6893,9 @@ static int bma2x2_probe(struct i2c_client *client,
setup_timer(&data->tap_timer, bma2x2_tap_timeout_handle,
(unsigned long)data);
#endif
hrtimer_init(&data->hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
data->hr_timer.function = my_hrtimer_callback;
INIT_WORK(&data->wq_hrtimer, wq_func_hrtimer);
dev_notice(&client->dev, "BMA2x2 driver probe successfully");
@ -6905,9 +6953,12 @@ static void bma2x2_early_suspend(struct early_suspend *h)
bma2x2_set_mode(data->bma2x2_client,
BMA2X2_MODE_SUSPEND, BMA_ENABLED_INPUT);
#ifndef CONFIG_BMA_ENABLE_NEWDATA_INT
#if 0
cancel_delayed_work_sync(&data->work);
flush_workqueue(data->workqueue);
#else
hrtimer_cancel(&data->hr_timer);
#endif
#endif
}
mutex_unlock(&data->enable_mutex);
@ -6923,8 +6974,12 @@ static void bma2x2_late_resume(struct early_suspend *h)
bma2x2_set_mode(data->bma2x2_client,
BMA2X2_MODE_NORMAL, BMA_ENABLED_INPUT);
#ifndef CONFIG_BMA_ENABLE_NEWDATA_INT
#if 0
queue_delayed_work(data->workqueue, &data->work,
msecs_to_jiffies(atomic_read(&data->delay)));
#else
hrtimer_start(&data->hr_timer, data->ktime, HRTIMER_MODE_REL);
#endif
#endif
}
mutex_unlock(&data->enable_mutex);
@ -6967,19 +7022,26 @@ static int bma2x2_suspend(struct device *dev, pm_message_t mesg)
{
struct i2c_client *client = to_i2c_client(dev);
struct bma2x2_data *data = i2c_get_clientdata(client);
int err;
mutex_lock(&data->enable_mutex);
if (atomic_read(&data->enable) == 1) {
bma2x2_set_mode(data->bma2x2_client,
BMA2X2_MODE_SUSPEND, BMA_ENABLED_INPUT);
#ifndef CONFIG_BMA_ENABLE_NEWDATA_INT
#if 0
cancel_delayed_work_sync(&data->work);
flush_workqueue(data->workqueue);
#else
hrtimer_cancel(&data->hr_timer);
#endif
#endif
}
mutex_unlock(&data->enable_mutex);
if (gsensor_info.sensor_power_ldo != NULL) {
regulator_disable(gsensor_info.sensor_power_ldo);
err = regulator_disable(gsensor_info.sensor_power_ldo);
if (err)
printk("bma2x2 power down failed\n");
/* msleep(500); */
}
return 0;
@ -6989,17 +7051,24 @@ static int bma2x2_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct bma2x2_data *data = i2c_get_clientdata(client);
int err;
if (gsensor_info.sensor_power_ldo != NULL) {
regulator_enable(gsensor_info.sensor_power_ldo);
err = regulator_enable(gsensor_info.sensor_power_ldo);
if (err)
printk("bma2x2 power on failed\n");
msleep(100);
}
}
mutex_lock(&data->enable_mutex);
if (atomic_read(&data->enable) == 1) {
bma2x2_set_mode(data->bma2x2_client,
BMA2X2_MODE_NORMAL, BMA_ENABLED_INPUT);
#ifndef CONFIG_BMA_ENABLE_NEWDATA_INT
#if 0
queue_delayed_work(data->workqueue, &data->work,
msecs_to_jiffies(atomic_read(&data->delay)));
#else
hrtimer_start(&data->hr_timer, data->ktime, HRTIMER_MODE_REL);
#endif
#endif
}
mutex_unlock(&data->enable_mutex);
@ -7111,7 +7180,9 @@ static int __init BMA2X2_init(void)
twi_id = gsensor_info.twi_id;
if (gsensor_info.sensor_power_ldo != NULL) {
regulator_enable(gsensor_info.sensor_power_ldo);
err = regulator_enable(gsensor_info.sensor_power_ldo);
if (err)
printk("bma2x2 power on failed\n");
msleep(500);
}

View file

@ -197,7 +197,9 @@ EXPORT_SYMBOL(bst_register_device);
*/
void bst_unregister_device(struct bst_dev *dev)
{
mutex_lock_interruptible(&bst_mutex);
int ret = mutex_lock_interruptible(&bst_mutex);
if (ret)
printk("mutex lock bst failed\n");
list_del_init(&dev->node);
mutex_unlock(&bst_mutex);
device_unregister(&dev->dev);

191
lichee/linux-4.9/drivers/input/sensor/mma865x.c Normal file → Executable file
View file

@ -37,6 +37,9 @@
//#include <mach/system.h>
//#include <mach/hardware.h>
#include <linux/hrtimer.h>
#include <linux/ktime.h>
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
@ -57,7 +60,7 @@
#define MMA8653_ID 0x5A
#define POLL_INTERVAL_MIN 1
#define POLL_INTERVAL_MAX 500
#define POLL_INTERVAL_MAX 1000
#define POLL_INTERVAL 100 /* msecs */
/* if sensor is standby ,set POLL_STOP_TIME to slow down the poll */
#define POLL_STOP_TIME 200
@ -183,6 +186,9 @@ static struct mma865x_data {
volatile int MMA865X_REG1;
volatile int MMA865X_DATA_REG;
#endif
struct hrtimer hr_timer;
struct work_struct wq_hrtimer;
ktime_t ktime;
} g_mma865x_data;
@ -354,7 +360,9 @@ static void report_abs(void)
static void mma865x_dev_poll(struct input_polled_dev *dev)
{
#if 0
report_abs();
#endif
}
static ssize_t mma865x_enable_show(struct device *dev,
@ -398,7 +406,11 @@ static ssize_t mma865x_enable_store(struct device *dev,
#if defined(CONFIG_HAS_EARLYSUSPEND) || defined(CONFIG_PM)
if (pdata->suspend_indator == 0)
#endif
#if 0
mma865x_idev->input->open(mma865x_idev->input);
#else
hrtimer_start(&g_mma865x_data.hr_timer, g_mma865x_data.ktime, HRTIMER_MODE_REL);
#endif
atomic_set(&pdata->active, MMA_ACTIVED);
dprintk(DEBUG_CONTROL_INFO, "mma enable setting active \n");
@ -412,7 +424,11 @@ static ssize_t mma865x_enable_store(struct device *dev,
ret = i2c_smbus_write_byte_data(client, MMA865X_CTRL_REG1,val & 0xFE);
mutex_unlock(&pdata->init_mutex);
if (!ret) {
mma865x_idev->input->close(mma865x_idev->input);
#if 0
mma865x_idev->input->close(mma865x_idev->input);
#else
hrtimer_cancel(&g_mma865x_data.hr_timer);
#endif
atomic_set(&pdata->active, MMA_STANDBY);
dprintk(DEBUG_CONTROL_INFO, "mma enable setting inactive \n");
@ -431,13 +447,13 @@ static ssize_t mma865x_delay_store(struct device *dev,struct device_attribute *a
unsigned long data;
int error;
error = strict_strtoul(buf, 10, &data);
error = kstrtoul(buf, 10, &data);
if (error)
return error;
if (data > POLL_INTERVAL_MAX)
data = POLL_INTERVAL_MAX;
mma865x_idev->poll_interval = data;
g_mma865x_data.ktime = ktime_set(0, data * NSEC_PER_MSEC);
return count;
}
@ -462,6 +478,17 @@ static void mma865x_init_events (struct work_struct *work)
mma865x_device_init(mma865x_i2c_client);
}
static void wq_func_hrtimer(struct work_struct *work)
{
report_abs();
}
static enum hrtimer_restart my_hrtimer_callback(struct hrtimer *timer)
{
schedule_work(&g_mma865x_data.wq_hrtimer);
hrtimer_forward_now(&g_mma865x_data.hr_timer, g_mma865x_data.ktime);
return HRTIMER_RESTART;
}
static int mma865x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
@ -492,8 +519,7 @@ static int mma865x_probe(struct i2c_client *client,
hwmon_dev = hwmon_device_register(&client->dev);
assert(!(IS_ERR(hwmon_dev)));
dev_info(&client->dev, "build time %s %s\n", __DATE__, __TIME__);
/* Initialize the MMA865X chip */
pdata->client = client;
pdata->chip_id = chip_id;
@ -562,7 +588,10 @@ static int mma865x_probe(struct i2c_client *client,
register_early_suspend(&g_mma865x_data.early_suspend);
g_mma865x_data.suspend_indator = 0;
#endif
hrtimer_init(&g_mma865x_data.hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
g_mma865x_data.hr_timer.function = my_hrtimer_callback;
INIT_WORK(&g_mma865x_data.wq_hrtimer, wq_func_hrtimer);
dprintk(DEBUG_INIT, "mma865x device driver probe successfully\n");
return 0;
err_create_sysfs:
@ -581,7 +610,11 @@ static int mma865x_remove(struct i2c_client *client)
cancel_work_sync(&mma865x_resume_work);
destroy_workqueue(mma865x_resume_wq);
sysfs_remove_group(&mma865x_idev->input->dev.kobj, &mma865x_attr_group);
mma865x_idev->input->close(mma865x_idev->input);
#if 0
mma865x_idev->input->close(mma865x_idev->input);
#else
hrtimer_cancel(&g_mma865x_data.hr_timer);
#endif
input_unregister_polled_device(mma865x_idev);
input_free_polled_device(mma865x_idev);
cancel_work_sync(&mma865x_init_work);
@ -618,7 +651,11 @@ static void mma865x_resume_events (struct work_struct *work)
mutex_unlock(&g_mma865x_data.init_mutex);
dprintk(DEBUG_SUSPEND, "mma865x active\n");
}
mma865x_idev->input->open(mma865x_idev->input);
#if 0
mma865x_idev->input->open(mma865x_idev->input);
#else
hrtimer_start(&g_mma865x_data.hr_timer, g_mma865x_data.ktime, HRTIMER_MODE_REL);
#endif
dprintk(DEBUG_INIT, "mma865x device init end\n");
return;
#endif
@ -627,6 +664,7 @@ static void mma865x_resume_events (struct work_struct *work)
#ifdef CONFIG_HAS_EARLYSUSPEND
static void mma865x_early_suspend(struct early_suspend *h)
{
int err;
struct mma865x_data *pdata =
container_of(h, struct mma865x_data, early_suspend);
@ -635,17 +673,23 @@ static void mma865x_early_suspend(struct early_suspend *h)
flush_workqueue(mma865x_resume_wq);
if (NORMAL_STANDBY == standby_type) {
mma865x_idev->input->close(mma865x_idev->input);
if ((atomic_read(&pdata->active)) == MMA_ACTIVED)
mma865x_device_stop(mma865x_i2c_client);
} else if (SUPER_STANDBY == standby_type) {
pdata->MMA865X_DATA_REG = i2c_smbus_read_byte_data(mma865x_i2c_client,
pdata->MMA865X_DATA_REG = i2c_smbus_read_byte_data(mma865x_i2c_client,
MMA865X_XYZ_DATA_CFG);
#if 0
mma865x_idev->input->close(mma865x_idev->input);
#else
hrtimer_cancel(&g_mma865x_data.hr_timer);
#endif
if ((atomic_read(&pdata->active)) == MMA_ACTIVED)
mma865x_device_stop(mma865x_i2c_client);
if (gsensor_info.sensor_power_ldo != NULL) {
err = regulator_disable(gsensor_info.sensor_power_ldo);
if (err)
printk("bma865x power down failed\n");
/* msleep(500); */
}
return;
}
@ -657,8 +701,11 @@ static void mma865x_late_resume(struct early_suspend *h)
container_of(h, struct mma865x_data, early_suspend);
dprintk(DEBUG_SUSPEND, "mma865x late resume %d\n", (atomic_read(&pdata->active)));
if (gsensor_info.sensor_power_ldo != NULL) {
val = regulator_enable(gsensor_info.sensor_power_ldo);
msleep(100);
}
if (NORMAL_STANDBY == standby_type) {
if ((atomic_read(&pdata->active)) == MMA_ACTIVED) {
mutex_lock(&pdata->init_mutex);
val = i2c_smbus_read_byte_data(mma865x_i2c_client,MMA865X_CTRL_REG1);
@ -666,26 +713,32 @@ static void mma865x_late_resume(struct early_suspend *h)
mutex_unlock(&pdata->init_mutex);
dprintk(DEBUG_SUSPEND, "mma865x active\n");
}
mma865x_idev->input->open(mma865x_idev->input);
} else if(SUPER_STANDBY == standby_type)
#if 0
mma865x_idev->input->open(mma865x_idev->input);
#else
hrtimer_start(&g_mma865x_data.hr_timer, g_mma865x_data.ktime, HRTIMER_MODE_REL);
#endif
queue_work(mma865x_resume_wq, &mma865x_resume_work);
pdata->suspend_indator = 0;
return;
}
#else
#ifdef CONFIG_PM
static int mma865x_resume(struct i2c_client *client)
static int mma865x_resume(struct device *dev)
{
int val = 0;
struct i2c_client *client = to_i2c_client(dev);
struct mma865x_data *pdata = i2c_get_clientdata(client);
int val = 0;
dprintk(DEBUG_SUSPEND, "mma865x resume %d\n", (atomic_read(&pdata->active)));
if (NORMAL_STANDBY == standby_type) {
if (gsensor_info.sensor_power_ldo != NULL) {
val = regulator_enable(gsensor_info.sensor_power_ldo);
msleep(100);
}
if ((atomic_read(&pdata->active)) == MMA_ACTIVED) {
mutex_lock(&pdata->init_mutex);
val = i2c_smbus_read_byte_data(mma865x_i2c_client,MMA865X_CTRL_REG1);
@ -693,8 +746,11 @@ static int mma865x_resume(struct i2c_client *client)
mutex_unlock(&pdata->init_mutex);
dprintk(DEBUG_SUSPEND, "mma865x active\n");
}
mma865x_idev->input->open(mma865x_idev->input);
} else if(SUPER_STANDBY == standby_type)
#if 0
mma865x_idev->input->open(mma865x_idev->input);
#else
hrtimer_start(&g_mma865x_data.hr_timer, g_mma865x_data.ktime, HRTIMER_MODE_REL);
#endif
queue_work(mma865x_resume_wq, &mma865x_resume_work);
pdata->suspend_indator = 0;
@ -702,27 +758,32 @@ static int mma865x_resume(struct i2c_client *client)
return 0;
}
static int mma865x_suspend(struct i2c_client *client, pm_message_t mesg)
static int mma865x_suspend(struct device *dev, pm_message_t mesg)
{
struct mma865x_data *pdata = i2c_get_clientdata(client);
struct i2c_client *client = to_i2c_client(dev);
struct mma865x_data *pdata = i2c_get_clientdata(client);
int err = 0;
dprintk(DEBUG_SUSPEND, "mma865x suspend\n");
pdata->suspend_indator = 1;
flush_workqueue(mma865x_resume_wq);
if (NORMAL_STANDBY == standby_type) {
mma865x_idev->input->close(mma865x_idev->input);
if ((atomic_read(&pdata->active)) == MMA_ACTIVED)
mma865x_device_stop(mma865x_i2c_client);
} else if (SUPER_STANDBY == standby_type) {
pdata->MMA865X_DATA_REG = i2c_smbus_read_byte_data(mma865x_i2c_client,
MMA865X_XYZ_DATA_CFG);
mma865x_idev->input->close(mma865x_idev->input);
#if 0
mma865x_idev->input->close(mma865x_idev->input);
#else
hrtimer_cancel(&g_mma865x_data.hr_timer);
#endif
if ((atomic_read(&pdata->active)) == MMA_ACTIVED)
mma865x_device_stop(mma865x_i2c_client);
}
return 0;
if (gsensor_info.sensor_power_ldo != NULL) {
err = regulator_disable(gsensor_info.sensor_power_ldo);
/* msleep(500); */
}
return err;
}
#endif
#endif
@ -733,22 +794,22 @@ static const struct i2c_device_id mma865x_id[] = {
};
MODULE_DEVICE_TABLE(i2c, mma865x_id);
static const struct of_device_id mma865x_of_match[] = {
{.compatible = "allwinner,sun8i-gsensor-para"},
{},
};
static struct i2c_driver mma865x_driver = {
.class = I2C_CLASS_HWMON,
.driver = {
.name = MMA865X_DRV_NAME,
.owner = THIS_MODULE,
.of_match_table = "allwinner,sun50i-gsensor-para",
.of_match_table = mma865x_of_match,
.suspend = mma865x_suspend,
.resume = mma865x_resume,
},
.probe = mma865x_probe,
.remove = mma865x_remove,
#ifdef CONFIG_HAS_EARLYSUSPEND
#else
#ifdef CONFIG_PM
.suspend = mma865x_suspend,
.resume = mma865x_resume,
#endif
#endif
.id_table = mma865x_id,
.detect = gsensor_detect,
.address_list = normal_i2c,
@ -756,36 +817,28 @@ static struct i2c_driver mma865x_driver = {
static int __init mma865x_init(void)
{
int ret = -1;
dprintk(DEBUG_INIT, "======%s=========. \n", __func__);
if (input_fetch_sysconfig_para(&(gsensor_info.input_type))) {
printk("%s: err.\n", __func__);
return -1;
} else{
ret = input_init_platform_resource(&(gsensor_info.input_type));
if (0 != ret){
printk("%s:ctp_ops.init_platform_resource err. \n", __func__);
int err;
if (input_sensor_startup(&(gsensor_info.input_type))) {
printk("%s: gsensor-bma2x2 fetch paras err.\n", __func__);
return -1;
} else{
err = input_sensor_init(&(gsensor_info.input_type));
if (0 != err) {
printk("%s: gsensor-mma865x initialize platform err.\n", __func__);
}
}
twi_id = gsensor_info.twi_id;
twi_id = gsensor_info.twi_id;
dprintk(DEBUG_INIT, "%s i2c twi is %d \n", __func__, twi_id);
input_set_power_enable(&(gsensor_info.input_type),1);
ret = i2c_add_driver(&mma865x_driver);
if (ret < 0) {
printk("add mma865x i2c driver failed\n");
return -ENODEV;
}
dprintk(DEBUG_INIT, "add mma865x i2c driver\n");
if (gsensor_info.sensor_power_ldo != NULL) {
err = regulator_enable(gsensor_info.sensor_power_ldo);
msleep(500);
}
return ret;
return i2c_add_driver(&mma865x_driver);
}
static void __exit mma865x_exit(void)
{
dprintk(DEBUG_INIT, "remove mma865x i2c driver.\n");

View file

@ -127,7 +127,6 @@ enum{
#define dprintk(level_mask,fmt,arg...) if(unlikely(debug_mask & level_mask)) \
printk("***CTP***"fmt, ## arg)
module_param_named(debug_mask,debug_mask,int,S_IRUGO | S_IWUSR | S_IWGRP);
/*********************************************************************************************/
/*------------------------------------------------------------------------------------------*/
@ -1701,6 +1700,7 @@ static int ft5x_ts_probe(struct i2c_client *client, const struct i2c_device_id *
set_bit(EV_ABS, input_dev->evbit);
set_bit(EV_KEY, input_dev->evbit);
set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
input_dev->name = CTP_NAME; //dev_name(&client->dev)
err = input_register_device(input_dev);

View file

@ -1,3 +1,6 @@
#VIN open kmsg for debug
subdir-ccflags-y := -DDEBUG
obj-$(CONFIG_CSI_VIN) += modules/sensor/
obj-$(CONFIG_CSI_VIN) += modules/actuator/
obj-$(CONFIG_CSI_VIN) += vin_io.o

View file

@ -363,6 +363,8 @@ static struct regval_list sensor_default_regs[] = {
{0xe8, 0xa0},
{0xe9, 0x60},
{0xfe, 0x00},
#if 1 /* /pheobe_cao */
{0xfe, 0x01},
{0x4f, 0x00},
{0x4f, 0x00},
@ -588,6 +590,8 @@ static struct regval_list sensor_default_regs[] = {
{0x7a, 0x54},
{0x7b, 0x55},
{0xfe, 0x00},
#endif
{0xfe, 0x02},
{0xc0, 0x01},
{0xC1, 0x44},
@ -612,7 +616,7 @@ static struct regval_list sensor_default_regs[] = {
{0x05, 0x01},
{0x06, 0x56},
{0x07, 0x00},
{0x08, 0x32},
{0x08, 0x14},
{0xfe, 0x01},
{0x25, 0x00},
{0x26, 0xfa},
@ -624,6 +628,7 @@ static struct regval_list sensor_default_regs[] = {
{0x2c, 0xd6},
{0x2d, 0x0b},
{0x2e, 0xb8},
{0x3c, 0x00},
{0xfe, 0x00},
{0xfe, 0x00},
{0xfa, 0x00},

View file

@ -326,8 +326,7 @@ static void sensor_try_format(struct v4l2_subdev *sd,
u32 code = MEDIA_BUS_FMT_YUYV8_2X8;
if (fmt->pad == SENSOR_PAD_SOURCE) {
if ((sd->entity.stream_count > 0 || info->use_current_win) &&
info->current_wins != NULL) {
if ((info->use_current_win) && (info->current_wins != NULL)) {
code = info->fmt->mbus_code;
*ws = info->current_wins;
*sf = info->fmt;

2
lichee/linux-4.9/drivers/pci/pci-sysfs.c Normal file → Executable file
View file

@ -563,7 +563,7 @@ static ssize_t driver_override_show(struct device *dev,
ssize_t len;
device_lock(dev);
len = snprintf(buf, PAGE_SIZE, "%s\n", pdev->driver_override);
len = sprintf(buf, "%s\n", pdev->driver_override);
device_unlock(dev);
return len;
}

13
lichee/linux-4.9/drivers/power/supply/axp/axp-charger.c Normal file → Executable file
View file

@ -713,7 +713,7 @@ static void axp_charging_monitor(struct work_struct *work)
struct power_supply_config psy_cfg = {};
static s32 pre_rest_vol;
static bool pre_bat_curr_dir;
static int pre_axp_usbvolflag;
axp_charger_update_state(chg_dev);
/* if no battery exist, then return */
@ -772,6 +772,17 @@ static void axp_charging_monitor(struct work_struct *work)
pre_bat_curr_dir = chg_dev->bat_current_direction;
power_supply_changed(chg_dev->batt);
}
if (axp_usbvolflag != pre_axp_usbvolflag) {
AXP_DEBUG(AXP_SPLY, chg_dev->chip->pmu_num,
"axp_usbvolflag vol change: %d->%d\n",
pre_axp_usbvolflag, axp_usbvolflag);
pre_axp_usbvolflag = axp_usbvolflag;
if (timer_pending(&chg_dev->usb_status_timer))
del_timer_sync(&chg_dev->usb_status_timer);
mod_timer(&chg_dev->usb_status_timer,
jiffies + msecs_to_jiffies(5 * 1000));
}
/* reschedule for the next time */
schedule_delayed_work(&chg_dev->work, chg_dev->interval);

21
lichee/linux-4.9/drivers/pwm/core.c Normal file → Executable file
View file

@ -463,8 +463,8 @@ int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state)
state->duty_cycle > state->period)
return -EINVAL;
/*if (!memcmp(state, &pwm->state, sizeof(*state)))*/
/*return 0;*/
if (!memcmp(state, &pwm->state, sizeof(*state)))
return 0;
if (pwm->chip->ops->apply) {
err = pwm->chip->ops->apply(pwm->chip, pwm, state);
@ -498,14 +498,17 @@ int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state)
pwm->state.polarity = state->polarity;
}
err = pwm->chip->ops->config(pwm->chip, pwm,
state->duty_cycle,
state->period);
if (err)
return err;
if (state->period != pwm->state.period ||
state->duty_cycle != pwm->state.duty_cycle) {
err = pwm->chip->ops->config(pwm->chip, pwm,
state->duty_cycle,
state->period);
if (err)
return err;
pwm->state.duty_cycle = state->duty_cycle;
pwm->state.period = state->period;
pwm->state.duty_cycle = state->duty_cycle;
pwm->state.period = state->period;
}
if (state->enabled != pwm->state.enabled) {
if (state->enabled) {

View file

@ -916,6 +916,7 @@ static ssize_t regulator_print_state(char *buf, int state)
return sprintf(buf, "unknown\n");
}
/* bpi, add regulator enable/disable sysfs control */
static ssize_t regulator_state_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{

5
lichee/linux-4.9/drivers/scsi/sg.c Normal file → Executable file
View file

@ -2072,11 +2072,12 @@ sg_get_rq_mark(Sg_fd * sfp, int pack_id)
if ((1 == resp->done) && (!resp->sg_io_owned) &&
((-1 == pack_id) || (resp->header.pack_id == pack_id))) {
resp->done = 2; /* guard against other readers */
break;
write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
return resp;
}
}
write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
return resp;
return NULL;
}
/* always adds to end of list */

15
lichee/linux-4.9/drivers/soc/sunxi/sunxi-sid.c Normal file → Executable file
View file

@ -404,14 +404,14 @@ static s32 sid_rd_soc_ver_from_ce(void)
bus_rst_reg = readl(ccu_base + 0x2c0);
ce_clk_reg = readl(ccu_base + 0x09c);
if ((bus_clk_reg&(1<<5)) && (bus_rst_reg&(1<<5))
&& (ce_clk_reg&(1<<31))) {
if ((bus_clk_reg&(1U<<5)) && (bus_rst_reg&(1U<<5))
&& (ce_clk_reg&(1U<<31))) {
SID_DBG("The CE module is already enable.\n");
} else {
/* enable ce clock */
writel(bus_clk_reg | (1<<5), ccu_base + 0x060);
writel(bus_rst_reg | (1<<5), ccu_base + 0x2c0);
writel(ce_clk_reg | (1<<31), ccu_base + 0x09c);
writel(bus_clk_reg | (1U<<5), ccu_base + 0x060);
writel(bus_rst_reg | (1U<<5), ccu_base + 0x2c0);
writel(ce_clk_reg | (1U<<31), ccu_base + 0x09c);
}
#if defined(CONFIG_ARCH_SUN8IW6)
@ -502,9 +502,10 @@ static void sid_chipid_init(void)
void sid_rd_soc_secure_status(void)
{
#if defined(CONFIG_TEE) && \
(defined(CONFIG_ARCH_SUN8IW7) || defined(CONFIG_ARCH_SUN50IW1) \
|| defined(CONFIG_ARCH_SUN8IW6))
(defined(CONFIG_ARCH_SUN8IW7) || defined(CONFIG_ARCH_SUN8IW6))
sunxi_soc_secure = 1;
#elif defined(CONFIG_ARCH_SUN50IW1)
sunxi_soc_secure = sunxi_smc_probe_secure();
#else
static s32 init_flag;
void __iomem *base = NULL;

9
lichee/linux-4.9/drivers/usb/core/config.c Normal file → Executable file
View file

@ -759,18 +759,21 @@ void usb_destroy_configuration(struct usb_device *dev)
return;
if (dev->rawdescriptors) {
for (i = 0; i < dev->descriptor.bNumConfigurations; i++)
for (i = 0; i < dev->descriptor.bNumConfigurations &&
i < USB_MAXCONFIG; i++)
kfree(dev->rawdescriptors[i]);
kfree(dev->rawdescriptors);
dev->rawdescriptors = NULL;
}
for (c = 0; c < dev->descriptor.bNumConfigurations; c++) {
for (c = 0; c < dev->descriptor.bNumConfigurations &&
c < USB_MAXCONFIG; c++) {
struct usb_host_config *cf = &dev->config[c];
kfree(cf->string);
for (i = 0; i < cf->desc.bNumInterfaces; i++) {
for (i = 0; i < cf->desc.bNumInterfaces &&
i < USB_MAXINTERFACES; i++) {
if (cf->intf_cache[i])
kref_put(&cf->intf_cache[i]->ref,
usb_release_interface_cache);

View file

@ -110,6 +110,12 @@ exit:
return ret;
}
void disp_device_show_builtin_patten(struct disp_device *dispdev, u32 patten)
{
if (dispdev)
disp_al_show_builtin_patten(dispdev->hwdev_index, patten);
}
u32 disp_device_usec_before_vblank(struct disp_device *dispdev)
{
int cur_line;

View file

@ -39,5 +39,6 @@ struct list_head *disp_device_get_list_head(void);
* @return :pointer of disp_device; NULL if not found
*/
struct disp_device *disp_device_get_from_priv(void *priv_data);
void disp_device_show_builtin_patten(struct disp_device *dispdev, u32 patten);
#endif

View file

@ -331,6 +331,7 @@ s32 disp_edp_set_func(struct disp_device *p_edp,
p_edpp->edp_func.tv_get_cur_line = func->tv_get_cur_line;
p_edpp->edp_func.tv_get_video_timing_info =
func->tv_get_video_timing_info;
p_edpp->edp_func.tv_show_builtin_patten = func->tv_show_builtin_patten;
return 0;
}
@ -557,8 +558,6 @@ static s32 disp_edp_exit(struct disp_device *p_edp)
disp_edp_disable(p_edp);
kfree(p_edp);
kfree(p_edpp);
p_edp = NULL;
p_edpp = NULL;
return 0;
}
@ -1012,19 +1011,40 @@ static s32 disp_edp_pwm_enable(struct disp_device *edp)
static s32 disp_edp_pwm_disable(struct disp_device *edp)
{
struct disp_edp_private_data *edpp = disp_edp_get_priv(edp);
s32 ret = -1;
struct pwm_device *pwm_dev;
if (!edp || !edpp) {
DE_WRN("NULL hdl!\n");
return DIS_FAIL;
}
if (edpp->pwm_info.dev)
return disp_sys_pwm_disable(edpp->pwm_info.dev);
if (edpp->pwm_info.dev) {
ret = disp_sys_pwm_disable(edpp->pwm_info.dev);
pwm_dev = (struct pwm_device *)edpp->pwm_info.dev;
/*following is for reset pwm state purpose*/
disp_sys_pwm_config(edpp->pwm_info.dev,
pwm_dev->state.duty_cycle - 1,
pwm_dev->state.period);
disp_sys_pwm_set_polarity(edpp->pwm_info.dev,
!edpp->pwm_info.polarity);
return ret;
}
DE_WRN("pwm device hdl is NULL\n");
return DIS_FAIL;
}
void disp_edp_show_builtin_patten(struct disp_device *edp, u32 patten)
{
struct disp_edp_private_data *p_edpp = disp_edp_get_priv(edp);
if (p_edpp->edp_func.tv_show_builtin_patten)
p_edpp->edp_func.tv_show_builtin_patten(p_edpp->edp_index,
patten);
}
/**
* @name :disp_init_edp
* @brief :register edp device
@ -1125,6 +1145,7 @@ s32 disp_init_edp(struct disp_bsp_init_para *para)
p_edp->pwm_disable = disp_edp_pwm_disable;
p_edp->power_enable = disp_edp_power_enable;
p_edp->power_disable = disp_edp_power_disable;
p_edp->show_builtin_patten = disp_edp_show_builtin_patten;
ret = p_edp->init(p_edp);
if (ret != 0) {
DE_INF("edp %d %d is not used\n", disp, hwdev_index);

View file

@ -1042,6 +1042,7 @@ s32 disp_init_hdmi(struct disp_bsp_init_para *para)
hdmi->usec_before_vblank =
disp_device_usec_before_vblank;
hdmi->get_fps = disp_hdmi_get_fps;
hdmi->show_builtin_patten = disp_device_show_builtin_patten;
hdmi->init(hdmi);
disp_device_register(hdmi);

View file

@ -847,7 +847,8 @@ static s32 disp_lcd_pin_cfg(struct disp_device *lcd, u32 bon)
((!strcmp(lcdp->lcd_cfg.lcd_pin_power[i], ""))
||
(!strcmp(lcdp->lcd_cfg.lcd_pin_power[i], "none"))))
disp_sys_power_enable(lcdp->lcd_cfg.lcd_pin_power[i]);
disp_sys_power_enable(lcdp->lcd_cfg.
lcd_pin_power[i]);
}
}
@ -866,7 +867,8 @@ static s32 disp_lcd_pin_cfg(struct disp_device *lcd, u32 bon)
((!strcmp(lcdp->lcd_cfg.lcd_pin_power[i], ""))
||
(!strcmp(lcdp->lcd_cfg.lcd_pin_power[i], "none"))))
disp_sys_power_disable(lcdp->lcd_cfg.lcd_pin_power[i]);
disp_sys_power_disable(lcdp->lcd_cfg.
lcd_pin_power[i]);
}
}
#endif
@ -948,14 +950,25 @@ static s32 disp_lcd_pwm_enable(struct disp_device *lcd)
static s32 disp_lcd_pwm_disable(struct disp_device *lcd)
{
struct disp_lcd_private_data *lcdp = disp_lcd_get_priv(lcd);
s32 ret = -1;
struct pwm_device *pwm_dev;
if ((lcd == NULL) || (lcdp == NULL)) {
DE_WRN("NULL hdl!\n");
return DIS_FAIL;
}
if (disp_lcd_is_used(lcd) && lcdp->pwm_info.dev)
return disp_sys_pwm_disable(lcdp->pwm_info.dev);
if (disp_lcd_is_used(lcd) && lcdp->pwm_info.dev) {
ret = disp_sys_pwm_disable(lcdp->pwm_info.dev);
pwm_dev = (struct pwm_device *)lcdp->pwm_info.dev;
/*following is for reset pwm state purpose*/
disp_sys_pwm_config(lcdp->pwm_info.dev,
pwm_dev->state.duty_cycle - 1,
pwm_dev->state.period);
disp_sys_pwm_set_polarity(lcdp->pwm_info.dev,
!lcdp->pwm_info.polarity);
return ret;
}
DE_WRN("pwm device hdl is NULL\n");
return DIS_FAIL;
@ -1549,6 +1562,7 @@ static s32 disp_lcd_fake_enable(struct disp_device *lcd)
ret = cal_real_frame_period(lcd);
if (ret)
DE_WRN("cal_real_frame_period fail:%d\n", ret);
disp_sys_pwm_set_polarity(lcdp->pwm_info.dev, lcdp->pwm_info.polarity);
disp_al_lcd_cfg(lcd->hwdev_index, &lcdp->panel_info,
&lcdp->panel_extend_info_set);
lcdp->open_flow.func_num = 0;
@ -2727,6 +2741,7 @@ s32 disp_init_lcd(struct disp_bsp_init_para *para)
lcd->get_fps = disp_lcd_get_fps;
lcd->set_color_temperature = disp_lcd_set_color_temperature;
lcd->get_color_temperature = disp_lcd_get_color_temperature;
lcd->show_builtin_patten = disp_device_show_builtin_patten;
lcd->init = disp_lcd_init;
lcd->exit = disp_lcd_exit;

View file

@ -182,7 +182,7 @@ s32 __disp_config_transfer2inner(
config_inner->info.fb.eotf = DISP_EOTF_UNDEF;
config_inner->info.fb.fbd_en = 0;
config_inner->info.fb.metadata_buf = 0;
config_inner->info.fb.fd = 0;
config_inner->info.fb.fd = -911;
config_inner->info.fb.metadata_size = 0;
config_inner->info.fb.metadata_flag = 0;
@ -1274,8 +1274,9 @@ disp_mgr_set_layer_config2(struct disp_manager *mgr,
if (lyr_cfg->config.enable == 0)
continue;
if (lyr_cfg->config.info.mode == LAYER_MODE_COLOR)
/*color mode and set_layer_config do no need to dma map*/
if (lyr_cfg->config.info.mode == LAYER_MODE_COLOR ||
lyr_cfg->config.info.fb.fd == -911)
continue;
item = disp_dma_map(lyr_cfg->config.info.fb.fd);

View file

@ -500,8 +500,6 @@ s32 disp_tv_exit(struct disp_device *ptv)
#endif
kfree(ptv);
kfree(ptvp);
ptv = NULL;
ptvp = NULL;
return 0;
}
@ -887,6 +885,7 @@ s32 disp_init_tv(void)
p_tv->set_gamma_tbl = disp_tv_set_gamma_tbl;
p_tv->is_in_safe_period = disp_device_is_in_safe_period;
p_tv->usec_before_vblank = disp_device_usec_before_vblank;
p_tv->show_builtin_patten = disp_device_show_builtin_patten;
p_tv->init(p_tv);
disp_device_register(p_tv);

View file

@ -884,6 +884,7 @@ struct disp_device *disp_vdevice_register(struct disp_vdevice_init_data *data)
vdevice->get_status = disp_device_get_status;
vdevice->is_in_safe_period = disp_device_is_in_safe_period;
vdevice->usec_before_vblank = disp_device_usec_before_vblank;
vdevice->show_builtin_patten = disp_device_show_builtin_patten;
vdevice->priv_data = (void *)vdevicep;
vdevice->init(vdevice);

View file

@ -438,8 +438,6 @@ static s32 disp_vga_exit(struct disp_device *vga)
kfree(vga);
kfree(vgap);
vga = NULL;
vgap = NULL;
return 0;
}
@ -795,6 +793,7 @@ s32 disp_init_vga(void)
vga->get_status = disp_device_get_status;
vga->is_in_safe_period = disp_device_is_in_safe_period;
vga->usec_before_vblank = disp_device_usec_before_vblank;
vga->show_builtin_patten = disp_device_show_builtin_patten;
vga->init(vga);
disp_device_register(vga);
disp++;

View file

@ -1037,6 +1037,7 @@ struct disp_device {
unsigned int io_index, u32 direction);
int (*get_panel_info)(struct disp_device *dispdev,
struct disp_panel_para *info);
void (*show_builtin_patten)(struct disp_device *dispdev, u32 patten);
};
/* manager */

View file

@ -1232,3 +1232,7 @@ s32 tcon_cmap(u32 sel, u32 mode, unsigned int lcd_cmap_tbl[2][3][4])
}
return 0;
}
void tcon_show_builtin_patten(u32 sel, u32 patten)
{
lcd_dev[sel]->tcon0_ctl.bits.src_sel = patten;
}

View file

@ -154,6 +154,7 @@ s32 tcon1_set_tv_mode(u32 sel, enum disp_output_type mode);
s32 hmdi_src_sel(u32 sel);
s32 tcon1_hdmi_color_remap(u32 sel, u32 onoff);
s32 tcon1_yuv_range(u32 sel, u32 onoff);
void tcon_show_builtin_patten(u32 sel, u32 patten);
#endif

View file

@ -823,4 +823,8 @@ int disp_al_get_display_size(unsigned int screen_id, unsigned int *width, unsign
return 0;
}
void disp_al_show_builtin_patten(u32 hwdev_index, u32 patten)
{
tcon_show_builtin_patten(hwdev_index, patten);
}
#endif

View file

@ -99,5 +99,6 @@ int disp_al_device_get_status(u32 screen_id);
int disp_al_get_fb_info(unsigned int sel, struct disp_layer_info *info);
int disp_al_get_display_size(unsigned int screen_id, unsigned int *width, unsigned int *height);
void disp_al_show_builtin_patten(u32 hwdev_index, u32 patten);
#endif

View file

@ -1791,3 +1791,8 @@ s32 tcon_cmap(u32 sel, u32 mode, unsigned int lcd_cmap_tbl[2][3][4])
}
return 0;
}
void tcon_show_builtin_patten(u32 sel, u32 patten)
{
lcd_dev[sel]->tcon0_ctl.bits.src_sel = patten;
}

View file

@ -125,6 +125,7 @@ s32 tcon_set_sync_pol(u32 sel, u32 ver_pol, u32 hor_pol);
s32 get_tcon_type_by_de_index(u32 de_index);
s32 tcon_vdpo_clk_enable(u32 sel, u32 en);
s32 vdpo_src_sel(u32 sel, u32 src);
void tcon_show_builtin_patten(u32 sel, u32 patten);
#if defined(SUPPORT_DSI)
extern __u32 dsi_pixel_bits[4];

View file

@ -1016,9 +1016,9 @@ int disp_al_lcd_get_start_delay(u32 screen_id, struct disp_panel_para *panel)
lcd_start_delay = ((tcon0_get_cpu_tri2_start_delay(screen_id)+1)
<< 3) * (panel->lcd_dclk_freq)
/ (panel->lcd_ht * de_clk_rate);
if (panel->lcd_if == LCD_IF_DSI)
return dsi_get_start_delay(screen_id) + lcd_start_delay;
}
if (panel->lcd_if == LCD_IF_DSI)
return lcd_start_delay;
#endif
return tcon_get_start_delay(screen_id,
al_priv.tcon_type[screen_id]);
@ -1585,3 +1585,8 @@ int disp_al_vdpo_disable(u32 screen_id)
}
return 0;
}
void disp_al_show_builtin_patten(u32 hwdev_index, u32 patten)
{
tcon_show_builtin_patten(hwdev_index, patten);
}

View file

@ -192,5 +192,6 @@ int disp_al_init_eink_ctrl_data_8(unsigned int disp, unsigned long wavedata_buf,
struct eink_timing_param *eink_timing_info, unsigned int i);
int disp_al_init_eink_ctrl_data_16(unsigned int disp, unsigned int wavedata_buf,
struct eink_timing_param *eink_timing_info);
void disp_al_show_builtin_patten(u32 hwdev_index, u32 patten);
#endif

View file

@ -1623,3 +1623,43 @@ s32 tcon_cmap(u32 sel, u32 mode, unsigned int lcd_cmap_tbl[2][3][4])
}
return 0;
}
s32 tcon1_black_src(u32 sel, u32 on_off, u32 color)
{
lcd_dev[sel]->tcon_ceu_coef_rr.bits.value = 0x100;
lcd_dev[sel]->tcon_ceu_coef_rg.bits.value = 0;
lcd_dev[sel]->tcon_ceu_coef_rb.bits.value = 0;
lcd_dev[sel]->tcon_ceu_coef_rc.bits.value = 0;
lcd_dev[sel]->tcon_ceu_coef_gr.bits.value = 0;
lcd_dev[sel]->tcon_ceu_coef_gg.bits.value = 0x100;
lcd_dev[sel]->tcon_ceu_coef_gb.bits.value = 0;
lcd_dev[sel]->tcon_ceu_coef_gc.bits.value = 0;
lcd_dev[sel]->tcon_ceu_coef_br.bits.value = 0;
lcd_dev[sel]->tcon_ceu_coef_bg.bits.value = 0;
lcd_dev[sel]->tcon_ceu_coef_bb.bits.value = 0x100;
lcd_dev[sel]->tcon_ceu_coef_bc.bits.value = 0;
lcd_dev[sel]->tcon_ceu_coef_rv.bits.max = (color == 0) ? 0x000 :
(color == 1) ? 0x040 : 0x200;
lcd_dev[sel]->tcon_ceu_coef_rv.bits.min = (color == 0) ? 0x000 :
(color == 1) ? 0x040 : 0x200;
lcd_dev[sel]->tcon_ceu_coef_gv.bits.max = (color == 0) ? 0x000 :
(color == 1) ? 0x200 : 0x040;
lcd_dev[sel]->tcon_ceu_coef_gv.bits.min = (color == 0) ? 0x000 :
(color == 1) ? 0x200 : 0x040;
lcd_dev[sel]->tcon_ceu_coef_bv.bits.max = (color == 0) ? 0x000 :
(color == 1) ? 0x200 : 0x040;
lcd_dev[sel]->tcon_ceu_coef_bv.bits.min = (color == 0) ? 0x000 :
(color == 1) ? 0x200 : 0x040;
lcd_dev[sel]->tcon_ceu_ctl.bits.ceu_en = on_off ? 1 : 0;
return 0;
}
void tcon_show_builtin_patten(u32 sel, u32 patten)
{
lcd_dev[sel]->tcon0_ctl.bits.src_sel = patten;
}

View file

@ -131,5 +131,6 @@ extern __u32 tcon_div;
extern s32 disp_delay_us(u32 us);
extern s32 disp_delay_ms(u32 ms);
extern int de_get_clk_rate(void);
void tcon_show_builtin_patten(u32 sel, u32 patten);
#endif

View file

@ -663,10 +663,9 @@ int disp_al_lcd_get_start_delay(u32 screen_id, struct disp_panel_para *panel)
lcd_start_delay = ((tcon0_get_cpu_tri2_start_delay(screen_id)+1)
<< 3) * (panel->lcd_dclk_freq)
/ (panel->lcd_ht*de_clk_rate);
if (panel->lcd_if == LCD_IF_DSI)
return dsi_get_start_delay(screen_id)+lcd_start_delay;
}
if (panel->lcd_if == LCD_IF_DSI)
return dsi_get_start_delay(screen_id)+lcd_start_delay;
else
#endif
return tcon_get_start_delay(screen_id,
al_priv.tcon_type[screen_id]);
@ -1084,7 +1083,7 @@ int disp_init_al(struct disp_bsp_init_para *para)
#if defined(SUPPORT_HDMI)
if (para->boot_info.type == DISP_OUTPUT_TYPE_HDMI) {
tcon_id = tcon_id - 1;
if ((tcon_id >= 0) && (tcon_id <= DEVICE_NUM))
if ((tcon_id >= 0) && (tcon_id < DEVICE_NUM))
al_priv.tcon_type[tcon_id] = 1;
else {
pr_err("%s-Error: error tcon id:%d\n",
@ -1150,3 +1149,7 @@ bool disp_al_get_direct_show_state(unsigned int disp)
return false;
}
void disp_al_show_builtin_patten(u32 hwdev_index, u32 patten)
{
tcon_show_builtin_patten(hwdev_index, patten);
}

View file

@ -126,6 +126,7 @@ int disp_al_edp_disable(u32 screen_id);
int disp_exit_al(void);
bool disp_al_get_direct_show_state(unsigned int disp);
void disp_al_show_builtin_patten(u32 hwdev_index, u32 patten);
#endif

View file

@ -22,7 +22,7 @@ struct disp_drv_info g_disp_drv;
/* alloc based on 4K byte */
#define MY_BYTE_ALIGN(x) (((x + (4*1024-1)) >> 12) << 12)
static u32 suspend_output_type[DISP_SCREEN_NUM] = {0};
static u32 suspend_output_type[4] = {0};
/*
* 0:normal;
* suspend_status&1 != 0:in early_suspend;
@ -89,7 +89,7 @@ static ssize_t disp_sys_show(struct device *dev,
num_screens = bsp_disp_feat_get_num_screens();
for (screen_id = 0; screen_id < num_screens; screen_id++) {
int width = 0, height = 0;
u32 width = 0, height = 0;
int fps = 0;
struct disp_health_info info;
@ -117,25 +117,25 @@ static ssize_t disp_sys_show(struct device *dev,
dispdev->get_bright(dispdev), fps / 10,
fps % 10);
} else if (dispdev->type == DISP_OUTPUT_TYPE_HDMI) {
unsigned int mode = dispdev->get_mode(dispdev);
int mode = dispdev->get_mode(dispdev);
count += sprintf(buf + count,
"\thdmi output mode(%d)\tfps:%d.%d",
mode, fps / 10, fps % 10);
} else if (dispdev->type == DISP_OUTPUT_TYPE_TV) {
unsigned int mode = dispdev->get_mode(dispdev);
int mode = dispdev->get_mode(dispdev);
count += sprintf(buf + count,
"\ttv output mode(%d)\tfps:%d.%d",
mode, fps / 10, fps % 10);
} else if (dispdev->type == DISP_OUTPUT_TYPE_VGA) {
unsigned int mode = dispdev->get_mode(dispdev);
int mode = dispdev->get_mode(dispdev);
count += sprintf(buf + count,
"\tvga output mode(%d)\tfps:%d.%d",
mode, fps / 10, fps % 10);
} else if (dispdev->type == DISP_OUTPUT_TYPE_VDPO) {
unsigned int mode = dispdev->get_mode(dispdev);
int mode = dispdev->get_mode(dispdev);
count += sprintf(buf + count,
"\tvdpo output mode(%d)\tfps:%d.%d",
@ -198,7 +198,7 @@ static DEVICE_ATTR(sys, 0660,
static ssize_t disp_disp_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", g_disp);
return sprintf(buf, "%u\n", g_disp);
}
static ssize_t disp_disp_store(struct device *dev,
@ -230,7 +230,7 @@ static DEVICE_ATTR(disp, 0660,
static ssize_t disp_enhance_mode_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", g_enhance_mode);
return sprintf(buf, "%u\n", g_enhance_mode);
}
static ssize_t disp_enhance_mode_store(struct device *dev,
@ -611,7 +611,7 @@ static DEVICE_ATTR(enhance_denoise, 0660,
static ssize_t disp_cvbs_enhance_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sprintf(buf, "%d\n", g_cvbs_enhance_mode);
return sprintf(buf, "%u\n", g_cvbs_enhance_mode);
}
static ssize_t disp_cvbs_enhance_store(struct device *dev,
@ -757,7 +757,7 @@ static ssize_t disp_yres_show(struct device *dev,
int num_screens = 2;
struct disp_manager *mgr = NULL;
struct disp_device *dispdev = NULL;
u32 width = 0, height;
u32 width = 0, height = 0;
num_screens = bsp_disp_feat_get_num_screens();
if (g_disp < num_screens)
@ -772,8 +772,35 @@ static ssize_t disp_yres_show(struct device *dev,
return sprintf(buf, "%d\n", height);
}
static ssize_t disp_colorbar_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
int err;
unsigned int val;
unsigned int num_screens;
struct disp_manager *mgr = NULL;
err = kstrtou32(buf, 10, &val);
if (err) {
pr_warn("Invalid size\n");
return err;
}
num_screens = bsp_disp_feat_get_num_screens();
if (g_disp < num_screens)
mgr = g_disp_drv.mgr[g_disp];
if (mgr && mgr->device && mgr->device->show_builtin_patten)
mgr->device->show_builtin_patten(mgr->device, val);
return count;
}
static DEVICE_ATTR(xres, 0660, disp_xres_show, NULL);
static DEVICE_ATTR(yres, 0660, disp_yres_show, NULL);
static DEVICE_ATTR(colorbar, 0660, NULL, disp_colorbar_store);
static struct attribute *disp_attributes[] = {
&dev_attr_sys.attr,
@ -790,6 +817,7 @@ static struct attribute *disp_attributes[] = {
&dev_attr_color_temperature.attr,
&dev_attr_xres.attr,
&dev_attr_yres.attr,
&dev_attr_colorbar.attr,
NULL
};
@ -932,7 +960,7 @@ static s32 parser_disp_init_para(const struct device_node *np,
init_para->using_device_config[0] = true;
}
if (DISP_SCREEN_NUM > 1) {
#if DISP_SCREEN_NUM > 1
/* screen1 */
if (of_property_read_u32(np,
"screen1_output_type",
@ -1026,8 +1054,7 @@ static s32 parser_disp_init_para(const struct device_node *np,
init_para->output_aspect_ratio[1] = value;
init_para->using_device_config[1] = true;
}
}
#endif
/* fb0 */
init_para->buffer_num[0] = 2;
if (of_property_read_u32(np, "fb0_buffer_num", &value) == 0)
@ -1052,7 +1079,7 @@ static s32 parser_disp_init_para(const struct device_node *np,
init_para->fb_height[0] = value;
/* fb1 */
if (DISP_SCREEN_NUM > 1) {
#if DISP_SCREEN_NUM > 1
init_para->buffer_num[1] = 2;
if (of_property_read_u32(np, "fb1_buffer_num", &value) == 0)
@ -1066,7 +1093,7 @@ static s32 parser_disp_init_para(const struct device_node *np,
if (of_property_read_u32(np, "fb1_height", &value) == 0)
init_para->fb_height[1] = value;
}
#endif
__inf("====display init para begin====\n");
__inf("b_init:%d\n", init_para->b_init);
@ -1153,11 +1180,8 @@ s32 disp_tv_register(struct disp_tv_func *func)
}
EXPORT_SYMBOL(disp_tv_register);
static void resume_proc(unsigned disp)
static void resume_proc(unsigned disp, struct disp_manager *mgr)
{
struct disp_manager *mgr = NULL;
mgr = g_disp_drv.mgr[disp];
if (!mgr || !mgr->device)
return;
@ -1167,13 +1191,15 @@ static void resume_proc(unsigned disp)
static void resume_work_0(struct work_struct *work)
{
resume_proc(0);
resume_proc(0, g_disp_drv.mgr[0]);
}
#if DISP_SCREEN_NUM > 1
static void resume_work_1(struct work_struct *work)
{
resume_proc(1);
resume_proc(1, g_disp_drv.mgr[1]);
}
#endif
int disp_device_set_config(struct disp_init_para *init,
unsigned int screen_id)
@ -1536,8 +1562,9 @@ static s32 disp_init(struct platform_device *pdev)
__inf("%s !\n", __func__);
INIT_WORK(&g_disp_drv.resume_work[0], resume_work_0);
if (DISP_SCREEN_NUM > 1)
INIT_WORK(&g_disp_drv.resume_work[1], resume_work_1);
#if DISP_SCREEN_NUM > 1
INIT_WORK(&g_disp_drv.resume_work[1], resume_work_1);
#endif
/* INIT_WORK(&g_disp_drv.resume_work[2], resume_work_2); */
INIT_WORK(&g_disp_drv.start_work, start_work);
INIT_LIST_HEAD(&g_disp_drv.sync_proc_list.list);
@ -1607,7 +1634,7 @@ static s32 disp_init(struct platform_device *pdev)
g_disp_drv.disp_init.output_aspect_ratio[para->boot_info.disp];
if (para->boot_info.sync == 1) {
__wrn("smooth display screen:%d type:%d\n", para->boot_info.disp,
__wrn("smooth display screen:%d type:%d", para->boot_info.disp,
para->boot_info.type);
g_disp_drv.disp_init.disp_mode = para->boot_info.disp;
g_disp_drv.disp_init.output_type[para->boot_info.disp] =

View file

@ -405,6 +405,11 @@ u32 dp_get_cur_line(u32 sel)
return edp_hal_get_cur_line(sel);
}
void dp_show_builtin_patten(u32 sel, u32 patten)
{
return edp_hal_show_builtin_patten(sel, patten);
}
void dp_set_reg_base(u32 sel, uintptr_t base)
{
edp_hal_set_reg_base(sel, base);

View file

@ -66,6 +66,7 @@ u32 dp_get_hpd_status(u32 sel);
void dp_moudle_en(u32 sel, u32 en);
s32 dp_hpd_enable(u32 sel, u32 lane_cnt, u64 bit_rate);
void dp_show_builtin_patten(u32 sel, u32 patten);
extern int training_aux_rd_interval_CR;
extern int training_aux_rd_interval_EQ;

View file

@ -656,3 +656,8 @@ u32 edp_hal_get_cur_line(u32 sel)
{
return dp_dev[sel]->dp_dbg_status0.bits.cur_line;
}
void edp_hal_show_builtin_patten(u32 sel, u32 patten)
{
dp_dev[sel]->dp_vid_ctrl.bits.vid_src_sel = patten;
}

View file

@ -53,5 +53,6 @@ u32 edp_hal_get_start_dly(u32 sel);
u32 edp_hal_get_cur_line(u32 sel);
void edp_hal_dp_module(u32 sel);
void edp_hal_dp_module_en(u32 sel, u32 en);
void edp_hal_show_builtin_patten(u32 sel, u32 patten);
#endif /*End of file*/

View file

@ -554,6 +554,11 @@ s32 edp_get_start_delay(u32 sel)
return ret;
}
void edp_show_builtin_patten(u32 sel, u32 patten)
{
dp_show_builtin_patten(sel, patten);
}
unsigned int edp_get_cur_line(u32 sel)
{
u32 ret = 0;
@ -648,6 +653,7 @@ static s32 edp_probe(struct platform_device *pdev)
edp_func.tv_irq_query = edp_irq_query;
edp_func.tv_get_startdelay = edp_get_start_delay;
edp_func.tv_get_cur_line = edp_get_cur_line;
edp_func.tv_show_builtin_patten = edp_show_builtin_patten;
ret = disp_set_edp_func(&edp_func);
if (ret) {
dev_err(&pdev->dev, "disp_set_edp_func edp%d fail!\n",

View file

@ -656,7 +656,7 @@ s32 hdmi_core_loop(void)
if (0 == (hdmi_hpd_mask & 0x100))
hdmi_hpd_event();
/*if (video_enable)*/
/*if (video_enable) bpi, fix hdmi hotplug issue*/
hdmi_core_set_video_enable(true);
case HDMI_State_HPD_Done:
@ -827,6 +827,7 @@ u32 hdmi_core_get_csc_type(void)
{
int csc = 1;
/*if (hdmi_edid_is_yuv() == 0) bpi, fix red screen issue when hdmi module load */
if ((hdmi_core_get_cts_enable() == 1) && (hdmi_edid_is_yuv() == 0))
csc = 0;

24
lichee/linux-4.9/fs/sdcardfs/file.c Normal file → Executable file
View file

@ -115,7 +115,11 @@ static long sdcardfs_unlocked_ioctl(struct file *file, unsigned int cmd,
goto out;
/* save current_cred and override it */
OVERRIDE_CRED(sbi, saved_cred, SDCARDFS_I(file_inode(file)));
saved_cred = override_fsids(sbi, SDCARDFS_I(file_inode(file))->data);
if (!saved_cred) {
err = -ENOMEM;
goto out;
}
if (lower_file->f_op->unlocked_ioctl)
err = lower_file->f_op->unlocked_ioctl(lower_file, cmd, arg);
@ -124,7 +128,7 @@ static long sdcardfs_unlocked_ioctl(struct file *file, unsigned int cmd,
if (!err)
sdcardfs_copy_and_fix_attrs(file_inode(file),
file_inode(lower_file));
REVERT_CRED(saved_cred);
revert_fsids(saved_cred);
out:
return err;
}
@ -146,12 +150,16 @@ static long sdcardfs_compat_ioctl(struct file *file, unsigned int cmd,
goto out;
/* save current_cred and override it */
OVERRIDE_CRED(sbi, saved_cred, SDCARDFS_I(file_inode(file)));
saved_cred = override_fsids(sbi, SDCARDFS_I(file_inode(file))->data);
if (!saved_cred) {
err = -ENOMEM;
goto out;
}
if (lower_file->f_op->compat_ioctl)
err = lower_file->f_op->compat_ioctl(lower_file, cmd, arg);
REVERT_CRED(saved_cred);
revert_fsids(saved_cred);
out:
return err;
}
@ -238,7 +246,11 @@ static int sdcardfs_open(struct inode *inode, struct file *file)
}
/* save current_cred and override it */
OVERRIDE_CRED(sbi, saved_cred, SDCARDFS_I(inode));
saved_cred = override_fsids(sbi, SDCARDFS_I(inode)->data);
if (!saved_cred) {
err = -ENOMEM;
goto out_err;
}
file->private_data =
kzalloc(sizeof(struct sdcardfs_file_info), GFP_KERNEL);
@ -268,7 +280,7 @@ static int sdcardfs_open(struct inode *inode, struct file *file)
sdcardfs_copy_and_fix_attrs(inode, sdcardfs_lower_inode(inode));
out_revert_cred:
REVERT_CRED(saved_cred);
revert_fsids(saved_cred);
out_err:
dput(parent);
return err;

213
lichee/linux-4.9/fs/sdcardfs/inode.c Normal file → Executable file
View file

@ -22,7 +22,6 @@
#include <linux/fs_struct.h>
#include <linux/ratelimit.h>
/* Do not directly use this function. Use OVERRIDE_CRED() instead. */
const struct cred *override_fsids(struct sdcardfs_sb_info *sbi,
struct sdcardfs_inode_data *data)
{
@ -46,7 +45,6 @@ const struct cred *override_fsids(struct sdcardfs_sb_info *sbi,
return old_cred;
}
/* Do not directly use this function, use REVERT_CRED() instead. */
void revert_fsids(const struct cred *old_cred)
{
const struct cred *cur_cred;
@ -74,7 +72,10 @@ static int sdcardfs_create(struct inode *dir, struct dentry *dentry,
}
/* save current_cred and override it */
OVERRIDE_CRED(SDCARDFS_SB(dir->i_sb), saved_cred, SDCARDFS_I(dir));
saved_cred = override_fsids(SDCARDFS_SB(dir->i_sb),
SDCARDFS_I(dir)->data);
if (!saved_cred)
return -ENOMEM;
sdcardfs_get_lower_path(dentry, &lower_path);
lower_dentry = lower_path.dentry;
@ -91,8 +92,11 @@ static int sdcardfs_create(struct inode *dir, struct dentry *dentry,
err = -ENOMEM;
goto out_unlock;
}
copied_fs->umask = 0;
task_lock(current);
current->fs = copied_fs;
current->fs->umask = 0;
task_unlock(current);
err = vfs_create2(lower_dentry_mnt, d_inode(lower_parent_dentry), lower_dentry, mode, want_excl);
if (err)
goto out;
@ -106,58 +110,18 @@ static int sdcardfs_create(struct inode *dir, struct dentry *dentry,
fixup_lower_ownership(dentry, dentry->d_name.name);
out:
task_lock(current);
current->fs = saved_fs;
task_unlock(current);
free_fs_struct(copied_fs);
out_unlock:
unlock_dir(lower_parent_dentry);
sdcardfs_put_lower_path(dentry, &lower_path);
REVERT_CRED(saved_cred);
revert_fsids(saved_cred);
out_eacces:
return err;
}
#if 0
static int sdcardfs_link(struct dentry *old_dentry, struct inode *dir,
struct dentry *new_dentry)
{
struct dentry *lower_old_dentry;
struct dentry *lower_new_dentry;
struct dentry *lower_dir_dentry;
u64 file_size_save;
int err;
struct path lower_old_path, lower_new_path;
OVERRIDE_CRED(SDCARDFS_SB(dir->i_sb));
file_size_save = i_size_read(d_inode(old_dentry));
sdcardfs_get_lower_path(old_dentry, &lower_old_path);
sdcardfs_get_lower_path(new_dentry, &lower_new_path);
lower_old_dentry = lower_old_path.dentry;
lower_new_dentry = lower_new_path.dentry;
lower_dir_dentry = lock_parent(lower_new_dentry);
err = vfs_link(lower_old_dentry, d_inode(lower_dir_dentry),
lower_new_dentry, NULL);
if (err || !d_inode(lower_new_dentry))
goto out;
err = sdcardfs_interpose(new_dentry, dir->i_sb, &lower_new_path);
if (err)
goto out;
fsstack_copy_attr_times(dir, d_inode(lower_new_dentry));
fsstack_copy_inode_size(dir, d_inode(lower_new_dentry));
set_nlink(d_inode(old_dentry),
sdcardfs_lower_inode(d_inode(old_dentry))->i_nlink);
i_size_write(d_inode(new_dentry), file_size_save);
out:
unlock_dir(lower_dir_dentry);
sdcardfs_put_lower_path(old_dentry, &lower_old_path);
sdcardfs_put_lower_path(new_dentry, &lower_new_path);
REVERT_CRED();
return err;
}
#endif
static int sdcardfs_unlink(struct inode *dir, struct dentry *dentry)
{
int err;
@ -174,7 +138,10 @@ static int sdcardfs_unlink(struct inode *dir, struct dentry *dentry)
}
/* save current_cred and override it */
OVERRIDE_CRED(SDCARDFS_SB(dir->i_sb), saved_cred, SDCARDFS_I(dir));
saved_cred = override_fsids(SDCARDFS_SB(dir->i_sb),
SDCARDFS_I(dir)->data);
if (!saved_cred)
return -ENOMEM;
sdcardfs_get_lower_path(dentry, &lower_path);
lower_dentry = lower_path.dentry;
@ -205,43 +172,11 @@ out:
unlock_dir(lower_dir_dentry);
dput(lower_dentry);
sdcardfs_put_lower_path(dentry, &lower_path);
REVERT_CRED(saved_cred);
revert_fsids(saved_cred);
out_eacces:
return err;
}
#if 0
static int sdcardfs_symlink(struct inode *dir, struct dentry *dentry,
const char *symname)
{
int err;
struct dentry *lower_dentry;
struct dentry *lower_parent_dentry = NULL;
struct path lower_path;
OVERRIDE_CRED(SDCARDFS_SB(dir->i_sb));
sdcardfs_get_lower_path(dentry, &lower_path);
lower_dentry = lower_path.dentry;
lower_parent_dentry = lock_parent(lower_dentry);
err = vfs_symlink(d_inode(lower_parent_dentry), lower_dentry, symname);
if (err)
goto out;
err = sdcardfs_interpose(dentry, dir->i_sb, &lower_path);
if (err)
goto out;
fsstack_copy_attr_times(dir, sdcardfs_lower_inode(dir));
fsstack_copy_inode_size(dir, d_inode(lower_parent_dentry));
out:
unlock_dir(lower_parent_dentry);
sdcardfs_put_lower_path(dentry, &lower_path);
REVERT_CRED();
return err;
}
#endif
static int touch(char *abs_path, mode_t mode)
{
struct file *filp = filp_open(abs_path, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, mode);
@ -282,7 +217,10 @@ static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
}
/* save current_cred and override it */
OVERRIDE_CRED(SDCARDFS_SB(dir->i_sb), saved_cred, SDCARDFS_I(dir));
saved_cred = override_fsids(SDCARDFS_SB(dir->i_sb),
SDCARDFS_I(dir)->data);
if (!saved_cred)
return -ENOMEM;
/* check disk space */
if (!check_min_free_space(dentry, 0, 1)) {
@ -308,8 +246,11 @@ static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
unlock_dir(lower_parent_dentry);
goto out_unlock;
}
copied_fs->umask = 0;
task_lock(current);
current->fs = copied_fs;
current->fs->umask = 0;
task_unlock(current);
err = vfs_mkdir2(lower_mnt, d_inode(lower_parent_dentry), lower_dentry, mode);
if (err) {
@ -358,23 +299,34 @@ static int sdcardfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
if (make_nomedia_in_obb ||
((pd->perm == PERM_ANDROID)
&& (qstr_case_eq(&dentry->d_name, &q_data)))) {
REVERT_CRED(saved_cred);
OVERRIDE_CRED(SDCARDFS_SB(dir->i_sb), saved_cred, SDCARDFS_I(d_inode(dentry)));
revert_fsids(saved_cred);
saved_cred = override_fsids(sbi,
SDCARDFS_I(d_inode(dentry))->data);
if (!saved_cred) {
pr_err("sdcardfs: failed to set up .nomedia in %s: %d\n",
lower_path.dentry->d_name.name,
-ENOMEM);
goto out;
}
set_fs_pwd(current->fs, &lower_path);
touch_err = touch(".nomedia", 0664);
if (touch_err) {
pr_err("sdcardfs: failed to create .nomedia in %s: %d\n",
lower_path.dentry->d_name.name, touch_err);
lower_path.dentry->d_name.name,
touch_err);
goto out;
}
}
out:
task_lock(current);
current->fs = saved_fs;
task_unlock(current);
free_fs_struct(copied_fs);
out_unlock:
sdcardfs_put_lower_path(dentry, &lower_path);
out_revert:
REVERT_CRED(saved_cred);
revert_fsids(saved_cred);
out_eacces:
return err;
}
@ -394,7 +346,10 @@ static int sdcardfs_rmdir(struct inode *dir, struct dentry *dentry)
}
/* save current_cred and override it */
OVERRIDE_CRED(SDCARDFS_SB(dir->i_sb), saved_cred, SDCARDFS_I(dir));
saved_cred = override_fsids(SDCARDFS_SB(dir->i_sb),
SDCARDFS_I(dir)->data);
if (!saved_cred)
return -ENOMEM;
/* sdcardfs_get_real_lower(): in case of remove an user's obb dentry
* the dentry on the original path should be deleted.
@ -419,44 +374,11 @@ static int sdcardfs_rmdir(struct inode *dir, struct dentry *dentry)
out:
unlock_dir(lower_dir_dentry);
sdcardfs_put_real_lower(dentry, &lower_path);
REVERT_CRED(saved_cred);
revert_fsids(saved_cred);
out_eacces:
return err;
}
#if 0
static int sdcardfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
dev_t dev)
{
int err;
struct dentry *lower_dentry;
struct dentry *lower_parent_dentry = NULL;
struct path lower_path;
OVERRIDE_CRED(SDCARDFS_SB(dir->i_sb));
sdcardfs_get_lower_path(dentry, &lower_path);
lower_dentry = lower_path.dentry;
lower_parent_dentry = lock_parent(lower_dentry);
err = vfs_mknod(d_inode(lower_parent_dentry), lower_dentry, mode, dev);
if (err)
goto out;
err = sdcardfs_interpose(dentry, dir->i_sb, &lower_path);
if (err)
goto out;
fsstack_copy_attr_times(dir, sdcardfs_lower_inode(dir));
fsstack_copy_inode_size(dir, d_inode(lower_parent_dentry));
out:
unlock_dir(lower_parent_dentry);
sdcardfs_put_lower_path(dentry, &lower_path);
REVERT_CRED();
return err;
}
#endif
/*
* The locking rules in sdcardfs_rename are complex. We could use a simpler
* superblock-level name-space lock for renames and copy-ups.
@ -485,7 +407,10 @@ static int sdcardfs_rename(struct inode *old_dir, struct dentry *old_dentry,
}
/* save current_cred and override it */
OVERRIDE_CRED(SDCARDFS_SB(old_dir->i_sb), saved_cred, SDCARDFS_I(new_dir));
saved_cred = override_fsids(SDCARDFS_SB(old_dir->i_sb),
SDCARDFS_I(new_dir)->data);
if (!saved_cred)
return -ENOMEM;
sdcardfs_get_real_lower(old_dentry, &lower_old_path);
sdcardfs_get_lower_path(new_dentry, &lower_new_path);
@ -532,7 +457,7 @@ out:
dput(lower_new_dir_dentry);
sdcardfs_put_real_lower(old_dentry, &lower_old_path);
sdcardfs_put_lower_path(new_dentry, &lower_new_path);
REVERT_CRED(saved_cred);
revert_fsids(saved_cred);
out_eacces:
return err;
}
@ -649,33 +574,7 @@ static int sdcardfs_permission(struct vfsmount *mnt, struct inode *inode, int ma
if (IS_POSIXACL(inode))
pr_warn("%s: This may be undefined behavior...\n", __func__);
err = generic_permission(&tmp, mask);
/* XXX
* Original sdcardfs code calls inode_permission(lower_inode,.. )
* for checking inode permission. But doing such things here seems
* duplicated work, because the functions called after this func,
* such as vfs_create, vfs_unlink, vfs_rename, and etc,
* does exactly same thing, i.e., they calls inode_permission().
* So we just let they do the things.
* If there are any security hole, just uncomment following if block.
*/
#if 0
if (!err) {
/*
* Permission check on lower_inode(=EXT4).
* we check it with AID_MEDIA_RW permission
*/
struct inode *lower_inode;
OVERRIDE_CRED(SDCARDFS_SB(inode->sb));
lower_inode = sdcardfs_lower_inode(inode);
err = inode_permission(lower_inode, mask);
REVERT_CRED();
}
#endif
return err;
}
static int sdcardfs_setattr_wrn(struct dentry *dentry, struct iattr *ia)
@ -753,7 +652,10 @@ static int sdcardfs_setattr(struct vfsmount *mnt, struct dentry *dentry, struct
goto out_err;
/* save current_cred and override it */
OVERRIDE_CRED(SDCARDFS_SB(dentry->d_sb), saved_cred, SDCARDFS_I(inode));
saved_cred = override_fsids(SDCARDFS_SB(dentry->d_sb),
SDCARDFS_I(inode)->data);
if (!saved_cred)
return -ENOMEM;
sdcardfs_get_lower_path(dentry, &lower_path);
lower_dentry = lower_path.dentry;
@ -812,7 +714,7 @@ static int sdcardfs_setattr(struct vfsmount *mnt, struct dentry *dentry, struct
out:
sdcardfs_put_lower_path(dentry, &lower_path);
REVERT_CRED(saved_cred);
revert_fsids(saved_cred);
out_err:
return err;
}
@ -895,13 +797,6 @@ const struct inode_operations sdcardfs_dir_iops = {
.setattr = sdcardfs_setattr_wrn,
.setattr2 = sdcardfs_setattr,
.getattr = sdcardfs_getattr,
/* XXX Following operations are implemented,
* but FUSE(sdcard) or FAT does not support them
* These methods are *NOT* perfectly tested.
.symlink = sdcardfs_symlink,
.link = sdcardfs_link,
.mknod = sdcardfs_mknod,
*/
};
const struct inode_operations sdcardfs_main_iops = {

9
lichee/linux-4.9/fs/sdcardfs/lookup.c Normal file → Executable file
View file

@ -428,7 +428,12 @@ struct dentry *sdcardfs_lookup(struct inode *dir, struct dentry *dentry,
}
/* save current_cred and override it */
OVERRIDE_CRED_PTR(SDCARDFS_SB(dir->i_sb), saved_cred, SDCARDFS_I(dir));
saved_cred = override_fsids(SDCARDFS_SB(dir->i_sb),
SDCARDFS_I(dir)->data);
if (!saved_cred) {
ret = ERR_PTR(-ENOMEM);
goto out_err;
}
sdcardfs_get_lower_path(parent, &lower_parent_path);
@ -459,7 +464,7 @@ struct dentry *sdcardfs_lookup(struct inode *dir, struct dentry *dentry,
out:
sdcardfs_put_lower_path(parent, &lower_parent_path);
REVERT_CRED(saved_cred);
revert_fsids(saved_cred);
out_err:
dput(parent);
return ret;

25
lichee/linux-4.9/fs/sdcardfs/sdcardfs.h Normal file → Executable file
View file

@ -88,31 +88,6 @@
(x)->i_mode = ((x)->i_mode & S_IFMT) | 0775;\
} while (0)
/* OVERRIDE_CRED() and REVERT_CRED()
* OVERRIDE_CRED()
* backup original task->cred
* and modifies task->cred->fsuid/fsgid to specified value.
* REVERT_CRED()
* restore original task->cred->fsuid/fsgid.
* These two macro should be used in pair, and OVERRIDE_CRED() should be
* placed at the beginning of a function, right after variable declaration.
*/
#define OVERRIDE_CRED(sdcardfs_sbi, saved_cred, info) \
do { \
saved_cred = override_fsids(sdcardfs_sbi, info->data); \
if (!saved_cred) \
return -ENOMEM; \
} while (0)
#define OVERRIDE_CRED_PTR(sdcardfs_sbi, saved_cred, info) \
do { \
saved_cred = override_fsids(sdcardfs_sbi, info->data); \
if (!saved_cred) \
return ERR_PTR(-ENOMEM); \
} while (0)
#define REVERT_CRED(saved_cred) revert_fsids(saved_cred)
/* Android 5.0 support */
/* Permission mode for a specific node. Controls how file permissions

8
lichee/linux-4.9/include/crypto/internal/hash.h Normal file → Executable file
View file

@ -80,6 +80,14 @@ int ahash_register_instance(struct crypto_template *tmpl,
struct ahash_instance *inst);
void ahash_free_instance(struct crypto_instance *inst);
int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
unsigned int keylen);
static inline bool crypto_shash_alg_has_setkey(struct shash_alg *alg)
{
return alg->setkey != shash_no_setkey;
}
int crypto_init_ahash_spawn(struct crypto_ahash_spawn *spawn,
struct hash_alg_common *alg,
struct crypto_instance *inst);

4
lichee/linux-4.9/include/linux/arm-smccc.h Normal file → Executable file
View file

@ -21,11 +21,11 @@
*/
#define ARM_SMCCC_STD_CALL 0
#define ARM_SMCCC_FAST_CALL 1
#define ARM_SMCCC_FAST_CALL 1U
#define ARM_SMCCC_TYPE_SHIFT 31
#define ARM_SMCCC_SMC_32 0
#define ARM_SMCCC_SMC_64 1
#define ARM_SMCCC_SMC_64 1U
#define ARM_SMCCC_CALL_CONV_SHIFT 30
#define ARM_SMCCC_OWNER_MASK 0x3F

3
lichee/linux-4.9/kernel/futex.c Normal file → Executable file
View file

@ -1947,6 +1947,9 @@ retry_private:
drop_count++;
}
if (nr_wake < 0 || nr_requeue < 0)
return -EINVAL;
/*
* We took an extra initial reference to the pi_state either
* in futex_proxy_trylock_atomic() or in lookup_pi_state(). We

10
lichee/linux-4.9/kernel/printk/printk.c Normal file → Executable file
View file

@ -580,6 +580,7 @@ static int log_store(int facility, int level,
memcpy(log_text(msg) + text_len, trunc_msg, trunc_msg_len);
msg->text_len += trunc_msg_len;
}
if (dict != NULL)
memcpy(log_dict(msg), dict, dict_len);
msg->dict_len = dict_len;
msg->facility = facility;
@ -753,8 +754,13 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
/* Ratelimit when not explicitly enabled. */
if (!(devkmsg_log & DEVKMSG_LOG_MASK_ON)) {
if (!___ratelimit(&user->rs, current->comm))
return ret;
/* allow android-init process write /dev/kmsg without ratelimit
* add by jiangbin 18/06/10
*/
if ((current->pid != 1) || (strcmp(current->comm, "init"))) {
if (!___ratelimit(&user->rs, current->comm))
return ret;
}
}
buf = kmalloc(len+1, GFP_KERNEL);

2
lichee/linux-4.9/kernel/resource.c Normal file → Executable file
View file

@ -172,7 +172,7 @@ static const struct file_operations proc_iomem_operations = {
static int __init ioresources_init(void)
{
proc_create("ioports", 0, NULL, &proc_ioports_operations);
proc_create("iomem", 0, NULL, &proc_iomem_operations);
proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
return 0;
}
__initcall(ioresources_init);

2
lichee/linux-4.9/kernel/trace/trace_printk.c Normal file → Executable file
View file

@ -304,7 +304,7 @@ static int t_show(struct seq_file *m, void *v)
if (!*fmt)
return 0;
seq_printf(m, "0x%lx : \"", *(unsigned long *)fmt);
seq_printf(m, "0x%lx : \"", 0L);
/*
* Tabs and new lines need to be converted.

4
lichee/linux-4.9/net/bluetooth/hidp/core.c Normal file → Executable file
View file

@ -431,8 +431,8 @@ static void hidp_del_timer(struct hidp_session *session)
del_timer(&session->timer);
}
static void hidp_process_report(struct hidp_session *session,
int type, const u8 *data, int len, int intr)
static void hidp_process_report(struct hidp_session *session, int type,
const u8 *data, unsigned int len, int intr)
{
if (len > HID_MAX_BUFFER_SIZE)
len = HID_MAX_BUFFER_SIZE;

13
lichee/linux-4.9/net/bridge/netfilter/ebtables.c Normal file → Executable file
View file

@ -2031,7 +2031,9 @@ static int ebt_size_mwt(struct compat_ebt_entry_mwt *match32,
if (match_kern)
match_kern->match_size = ret;
WARN_ON(type == EBT_COMPAT_TARGET && size_left);
if (WARN_ON(type == EBT_COMPAT_TARGET && size_left))
return -EINVAL;
match32 = (struct compat_ebt_entry_mwt *) buf;
}
@ -2087,6 +2089,15 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base,
*
* offsets are relative to beginning of struct ebt_entry (i.e., 0).
*/
for (i = 0; i < 4 ; ++i) {
if (offsets[i] >= *total)
return -EINVAL;
if (i == 0)
continue;
if (offsets[i-1] > offsets[i])
return -EINVAL;
}
for (i = 0, j = 1 ; j < 4 ; j++, i++) {
struct compat_ebt_entry_mwt *match32;
unsigned int size;

10
lichee/linux-4.9/net/ipv6/ip6_output.c Normal file → Executable file
View file

@ -1260,14 +1260,16 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
v6_cork->tclass = ipc6->tclass;
if (rt->dst.flags & DST_XFRM_TUNNEL)
mtu = np->pmtudisc >= IPV6_PMTUDISC_PROBE ?
rt->dst.dev->mtu : dst_mtu(&rt->dst);
READ_ONCE(rt->dst.dev->mtu) : dst_mtu(&rt->dst);
else
mtu = np->pmtudisc >= IPV6_PMTUDISC_PROBE ?
rt->dst.dev->mtu : dst_mtu(rt->dst.path);
READ_ONCE(rt->dst.dev->mtu) : dst_mtu(rt->dst.path);
if (np->frag_size < mtu) {
if (np->frag_size)
mtu = np->frag_size;
}
if (mtu < IPV6_MIN_MTU)
return -EINVAL;
cork->base.fragsize = mtu;
if (dst_allfrag(rt->dst.path))
cork->base.flags |= IPCORK_ALLFRAG;
@ -1800,8 +1802,10 @@ struct sk_buff *ip6_make_skb(struct sock *sk,
cork.base.opt = NULL;
v6_cork.opt = NULL;
err = ip6_setup_cork(sk, &cork, &v6_cork, ipc6, rt, fl6);
if (err)
if (err) {
ip6_cork_release(&cork, &v6_cork);
return ERR_PTR(err);
}
if (ipc6->dontfrag < 0)
ipc6->dontfrag = inet6_sk(sk)->dontfrag;

46
lichee/linux-4.9/security/keys/request_key.c Normal file → Executable file
View file

@ -250,11 +250,12 @@ static int construct_key(struct key *key, const void *callout_info,
* The keyring selected is returned with an extra reference upon it which the
* caller must release.
*/
static void construct_get_dest_keyring(struct key **_dest_keyring)
static int construct_get_dest_keyring(struct key **_dest_keyring)
{
struct request_key_auth *rka;
const struct cred *cred = current_cred();
struct key *dest_keyring = *_dest_keyring, *authkey;
int ret;
kenter("%p", dest_keyring);
@ -263,6 +264,8 @@ static void construct_get_dest_keyring(struct key **_dest_keyring)
/* the caller supplied one */
key_get(dest_keyring);
} else {
bool do_perm_check = true;
/* use a default keyring; falling through the cases until we
* find one that we actually have */
switch (cred->jit_keyring) {
@ -277,8 +280,10 @@ static void construct_get_dest_keyring(struct key **_dest_keyring)
dest_keyring =
key_get(rka->dest_keyring);
up_read(&authkey->sem);
if (dest_keyring)
if (dest_keyring) {
do_perm_check = false;
break;
}
}
case KEY_REQKEY_DEFL_THREAD_KEYRING:
@ -313,11 +318,29 @@ static void construct_get_dest_keyring(struct key **_dest_keyring)
default:
BUG();
}
/*
* Require Write permission on the keyring. This is essential
* because the default keyring may be the session keyring, and
* joining a keyring only requires Search permission.
*
* However, this check is skipped for the "requestor keyring" so
* that /sbin/request-key can itself use request_key() to add
* keys to the original requestor's destination keyring.
*/
if (dest_keyring && do_perm_check) {
ret = key_permission(make_key_ref(dest_keyring, 1),
KEY_NEED_WRITE);
if (ret) {
key_put(dest_keyring);
return ret;
}
}
}
*_dest_keyring = dest_keyring;
kleave(" [dk %d]", key_serial(dest_keyring));
return;
return 0;
}
/*
@ -443,11 +466,15 @@ static struct key *construct_key_and_link(struct keyring_search_context *ctx,
if (ctx->index_key.type == &key_type_keyring)
return ERR_PTR(-EPERM);
user = key_user_lookup(current_fsuid());
if (!user)
return ERR_PTR(-ENOMEM);
ret = construct_get_dest_keyring(&dest_keyring);
if (ret)
goto error;
construct_get_dest_keyring(&dest_keyring);
user = key_user_lookup(current_fsuid());
if (!user) {
ret = -ENOMEM;
goto error_put_dest_keyring;
}
ret = construct_alloc_key(ctx, dest_keyring, flags, user, &key);
key_user_put(user);
@ -462,7 +489,7 @@ static struct key *construct_key_and_link(struct keyring_search_context *ctx,
} else if (ret == -EINPROGRESS) {
ret = 0;
} else {
goto couldnt_alloc_key;
goto error_put_dest_keyring;
}
key_put(dest_keyring);
@ -472,8 +499,9 @@ static struct key *construct_key_and_link(struct keyring_search_context *ctx,
construction_failed:
key_negate_and_link(key, key_negative_timeout, NULL, NULL);
key_put(key);
couldnt_alloc_key:
error_put_dest_keyring:
key_put(dest_keyring);
error:
kleave(" = %d", ret);
return ERR_PTR(ret);
}

19
lichee/linux-4.9/sound/soc/sunxi/sun50iw1-codec.c Normal file → Executable file
View file

@ -422,6 +422,9 @@ static int codec_init(struct sunxi_codec *sunxi_internal_codec)
snd_soc_update_bits(sunxi_internal_codec->codec, MIC2_CTRL,
(0x7<<MIC2BOOST),
(sunxi_internal_codec->gain_config.headsetmicgain<<MIC2BOOST));
snd_soc_update_bits(sunxi_internal_codec->codec, ADC_CTRL,
(0x7 << ADCG),
(sunxi_internal_codec->gain_config.adcinputgain << ADCG));
snd_soc_update_bits(sunxi_internal_codec->codec, MIX_DAC_CTRL,
(0x1<<DACALEN), (1<<DACALEN));
snd_soc_update_bits(sunxi_internal_codec->codec, MIX_DAC_CTRL,
@ -812,7 +815,7 @@ static int dmic_mux_ev(struct snd_soc_dapm_widget *w,
static int set_src_function(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{
struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
struct snd_soc_codec *codec = snd_soc_component_to_codec(snd_kcontrol_chip(kcontrol));
/* struct sunxi_codec *sunxi_internal_codec = snd_soc_codec_get_drvdata(codec); */
src_function_en = ucontrol->value.integer.value[0];
@ -2459,12 +2462,12 @@ static ssize_t store_audio_reg(struct device *dev, struct device_attribute *attr
int ret;
int rw_flag;
int reg_val_read;
int input_reg_val = 0;
unsigned int input_reg_val = 0;
int input_reg_group = 0;
int input_reg_offset = 0;
unsigned int input_reg_offset = 0;
ret = sscanf(buf, "%d,%d,0x%x,0x%x", &rw_flag, &input_reg_group, &input_reg_offset, &input_reg_val);
printk("ret:%d, reg_group:%d, reg_offset:%d, reg_val:0x%x\n", ret, input_reg_group, input_reg_offset, input_reg_val);
printk("ret:%d, reg_group:%d, reg_offset:0x%x, reg_val:0x%x\n", ret, input_reg_group, input_reg_offset, input_reg_val);
if (!(input_reg_group == 1 || input_reg_group == 2)) {
pr_err("not exist reg group\n");
@ -2710,6 +2713,14 @@ static int sunxi_internal_codec_probe(struct platform_device *pdev)
sunxi_internal_codec->gain_config.headsetmicgain = temp_val;
}
ret = of_property_read_u32(node, "adcinputgain", &temp_val);
if (ret < 0) {
pr_err("[audio-codec]adcinputgain configurations missing or invalid.\n");
sunxi_internal_codec->gain_config.adcinputgain = 0x3;
} else {
sunxi_internal_codec->gain_config.adcinputgain = temp_val;
}
ret = of_property_read_u32(node, "adcagc_cfg", &temp_val);
if (ret < 0) {
pr_err("[audio-codec]adcagc_cfg configurations missing or invalid.\n");

1
lichee/linux-4.9/sound/soc/sunxi/sun50iw1-codec.h Normal file → Executable file
View file

@ -2047,6 +2047,7 @@ struct gain_config {
u32 earpiecevol;
u32 maingain;
u32 headsetmicgain;
u32 adcinputgain;
u32 dac_digital_vol;
};