omx: add two layer support [3/6]

PD#SWPL-85

Problem:
Need support two video layers feature

Solution:
1: Add videosync.
2: amlvideo support multi-instance

Verify:
U212

Change-Id: I3570fad361ba5bd388dd46c51a66da056fa7a1fd
Signed-off-by: jintao xu <jintao.xu@amlogic.com>
This commit is contained in:
jintao xu
2019-01-16 10:14:49 +08:00
committed by Jianxin Pan
parent 616354015e
commit 8a4749902d
16 changed files with 1554 additions and 16 deletions

View File

@@ -14785,3 +14785,11 @@ F: drivers/amlogic/media/gdc/src/platform/system_log.c
AMLOGIC IRCUT DRIVER
M: Dianzhong Huo <dianzhong.huo@amlogic.com>
F: drivers/amlogic/ircut/
AMLOGIC VIDEOSYNC
M: Jintao Xu <jintao.xu@amlogic.com>
F: drivers/amlogic/media/video_processor/videosync/Kconfig
F: drivers/amlogic/media/video_processor/videosync/Makefile
F: drivers/amlogic/media/video_processor/videosync/vfp.h
F: drivers/amlogic/media/video_processor/videosync/videosync.h
F: drivers/amlogic/media/video_processor/videosync/videosync.c

View File

@@ -324,6 +324,7 @@ CONFIG_AMLOGIC_POST_PROCESS_MANAGER_PPSCALER=y
CONFIG_AMLOGIC_VIDEOBUF2_ION=y
CONFIG_AMLOGIC_IONVIDEO=y
CONFIG_AMLOGIC_PIC_DEC=y
CONFIG_AMLOGIC_VIDEOSYNC=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION=y

View File

@@ -319,6 +319,7 @@ CONFIG_AMLOGIC_POST_PROCESS_MANAGER_PPSCALER=y
CONFIG_AMLOGIC_VIDEOBUF2_ION=y
CONFIG_AMLOGIC_IONVIDEO=y
CONFIG_AMLOGIC_PIC_DEC=y
CONFIG_AMLOGIC_VIDEOSYNC=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION=y

View File

@@ -280,6 +280,7 @@ CONFIG_AMLOGIC_POST_PROCESS_MANAGER=y
CONFIG_AMLOGIC_POST_PROCESS_MANAGER_PPSCALER=y
CONFIG_AMLOGIC_VIDEOBUF2_ION=y
CONFIG_AMLOGIC_IONVIDEO=y
CONFIG_AMLOGIC_VIDEOSYNC=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION=y

View File

@@ -979,7 +979,7 @@ bool afbc_is_supported(void)
if (is_meson_txlx_cpu()
|| is_meson_g12a_cpu()
/*|| is_meson_tl1_cpu()*/)
ret = true;
ret = false;
return ret;
}

View File

@@ -17,7 +17,7 @@ source "drivers/amlogic/media/video_processor/video_dev/Kconfig"
source "drivers/amlogic/media/video_processor/ppmgr/Kconfig"
source "drivers/amlogic/media/video_processor/ionvideo/Kconfig"
source "drivers/amlogic/media/video_processor/pic_dev/Kconfig"
source "drivers/amlogic/media/video_processor/videosync/Kconfig"
endif
endmenu

View File

@@ -2,3 +2,4 @@ obj-$(CONFIG_AMLOGIC_V4L_VIDEO2) += video_dev/
obj-$(CONFIG_AMLOGIC_POST_PROCESS_MANAGER) += ppmgr/
obj-$(CONFIG_AMLOGIC_IONVIDEO) += ionvideo/
obj-$(CONFIG_AMLOGIC_PIC_DEC) += pic_dev/
obj-$(CONFIG_AMLOGIC_VIDEOSYNC) += videosync/

View File

@@ -70,6 +70,8 @@ AMLVIDEO_MINOR_VERSION, AMLVIDEO_RELEASE)
#define RECEIVER_NAME "amlvideo"
#define PROVIDER_NAME "amlvideo"
#define RECEIVER_NAME_PIP "aml_video"
#define PROVIDER_NAME_PIP "aml_video"
#define AMLVIDEO_POOL_SIZE 16
/*extern bool omx_secret_mode;*/
@@ -82,11 +84,12 @@ MODULE_AUTHOR("amlogic-sh");
MODULE_LICENSE("GPL");
/* static u32 vpts_remainder; */
static unsigned int video_nr_base = 10;
static unsigned int video_nr_base_second = 23;
/* module_param(video_nr_base, uint, 0644); */
/* MODULE_PARM_DESC(video_nr_base, "videoX start number, 10 is defaut"); */
#ifdef CONFIG_AMLOGIC_MEDIA_MULTI_DEC
static unsigned int n_devs = 1;
static unsigned int n_devs = 2;
#else
static unsigned int n_devs = 1;
#endif
@@ -887,7 +890,10 @@ static int __init amlvideo_create_instance(int inst)
vfd->dev_debug = debug;
vfd->v4l2_dev = &dev->v4l2_dev;
dev->amlvideo_v4l_num = inst * 10 + video_nr_base;
if (inst == 0)
dev->amlvideo_v4l_num = video_nr_base;
else
dev->amlvideo_v4l_num = (inst - 1) + video_nr_base_second;
/* //////////////////////////////////////// */
/* vfd->v4l2_dev = &dev->v4l2_dev; */
/* //////////////////////////////////////// */
@@ -898,18 +904,19 @@ static int __init amlvideo_create_instance(int inst)
goto rel_vdev;
dev->inst = inst;
#if 0
snprintf(dev->vf_receiver_name, AMLVIDEO_VF_NAME_SIZE,
(0) ? RECEIVER_NAME : RECEIVER_NAME ".%x",
inst & 0xff);
snprintf(dev->vf_provider_name, AMLVIDEO_VF_NAME_SIZE,
(0) ? PROVIDER_NAME : PROVIDER_NAME ".%x",
inst & 0xff);
#else
memcpy(dev->vf_receiver_name, RECEIVER_NAME, sizeof(RECEIVER_NAME));
memcpy(dev->vf_provider_name, PROVIDER_NAME, sizeof(PROVIDER_NAME));
#endif
if (inst != 0) {
snprintf(dev->vf_receiver_name, AMLVIDEO_VF_NAME_SIZE,
RECEIVER_NAME_PIP ".%x", inst & 0xff);
snprintf(dev->vf_provider_name, AMLVIDEO_VF_NAME_SIZE,
PROVIDER_NAME_PIP ".%x", inst & 0xff);
} else {
memcpy(dev->vf_receiver_name, RECEIVER_NAME,
sizeof(RECEIVER_NAME));
memcpy(dev->vf_provider_name, PROVIDER_NAME,
sizeof(PROVIDER_NAME));
}
vf_receiver_init(&dev->video_vf_recv,
dev->vf_receiver_name,

View File

@@ -0,0 +1,11 @@
menu "Amlogic videosync support"
config AMLOGIC_VIDEOSYNC
tristate "amlogic videosync device support"
select VIDEO_DEV
default n
---help---
Select to enable "Amlogic videosync support.
endmenu

View File

@@ -0,0 +1,3 @@
asflags-y=-mfloat-abi=softfp -mfpu=neon
obj-$(CONFIG_AMLOGIC_VIDEOSYNC) += videosync.o

View File

@@ -0,0 +1,112 @@
/*
* drivers/amlogic/media/video_processor/videosync/vfp.h
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* 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 __VFP_H_
#define __VFP_H_
struct vfq_s {
int rp;
int wp;
int size;
int pre_rp;
int pre_wp;
struct vframe_s **pool;
};
static inline void vfq_lookup_start(struct vfq_s *q)
{
q->pre_rp = q->rp;
q->pre_wp = q->wp;
}
static inline void vfq_lookup_end(struct vfq_s *q)
{
q->rp = q->pre_rp;
q->wp = q->pre_wp;
}
static inline void vfq_init(struct vfq_s *q, u32 size, struct vframe_s **pool)
{
q->rp = q->wp = 0;
q->size = size;
q->pool = pool;
}
static inline bool vfq_empty(struct vfq_s *q)
{
return q->rp == q->wp;
}
static inline bool vfq_full(struct vfq_s *q)
{
bool ret = (((q->wp+1) % q->size) == q->rp);
return ret;
}
static inline void vfq_push(struct vfq_s *q, struct vframe_s *vf)
{
int wp = q->wp;
/*ToDo*/
smp_mb();
q->pool[wp] = vf;
/*ToDo*/
smp_wmb();
q->wp = (wp == (q->size - 1)) ? 0 : (wp + 1);
}
static inline struct vframe_s *vfq_pop(struct vfq_s *q)
{
struct vframe_s *vf;
int rp;
if (vfq_empty(q))
return NULL;
rp = q->rp;
/*ToDo*/
smp_rmb();
vf = q->pool[rp];
/*ToDo*/
smp_mb();
q->rp = (rp == (q->size - 1)) ? 0 : (rp + 1);
return vf;
}
static inline struct vframe_s *vfq_peek(struct vfq_s *q)
{
return (vfq_empty(q)) ? NULL : q->pool[q->rp];
}
static inline int vfq_level(struct vfq_s *q)
{
int level = q->wp - q->rp;
if (level < 0)
level += q->size;
return level;
}
#endif /* __VFP_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,141 @@
/*
* drivers/amlogic/media/video_processor/videosync/videosync.h
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* 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 _VIDEOSYNC_H
#define _VIDEOSYNC_H
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/videodev2.h>
#include <linux/kthread.h>
#include <linux/freezer.h>
#include <linux/delay.h>
#include <linux/completion.h>
#include <linux/mm.h>
#include <linux/amlogic/media/vfm/vframe.h>
#include <linux/amlogic/media/vfm/vframe_provider.h>
#include <linux/amlogic/media/vfm/vframe_receiver.h>
#include <linux/amlogic/media/vfm/vframe.h>
#include <linux/amlogic/media/frame_sync/timestamp.h>
#include "vfp.h"
#include <linux/spinlock.h>
#define VIDEOSYNC_S_COUNT 1
#define VIDEOSYNC_ACTIVE 0
#define VIDEOSYNC_INACTIVE_REQ 1
#define VIDEOSYNC_INACTIVE 2
struct videosync_priv_s {
int vp_id; /* reserved */
struct videosync_s *dev_s;
};
struct videosync_dev {
struct videosync_s *video_prov;
struct task_struct *kthread;
struct completion thread_active;
struct mutex vp_mutex;
spinlock_t dev_s_num_slock;
u32 active_dev_s_num;
};
extern bool omx_secret_mode;
#define VIDEOSYNC_IOC_MAGIC 'P'
#define VIDEOSYNC_IOC_ALLOC_ID _IOR(VIDEOSYNC_IOC_MAGIC, 0x00, int)
#define VIDEOSYNC_IOC_FREE_ID _IOW(VIDEOSYNC_IOC_MAGIC, 0x01, int)
#define VIDEOSYNC_IOC_SET_FREERUN_MODE _IOW(VIDEOSYNC_IOC_MAGIC, 0x02, int)
#define VIDEOSYNC_IOC_GET_FREERUN_MODE _IOR(VIDEOSYNC_IOC_MAGIC, 0x03, int)
#define VIDEOSYNC_IOC_SET_OMX_VPTS _IOW(VIDEOSYNC_IOC_MAGIC, 0x04, unsigned int)
#define VIDEOSYNC_IOC_GET_OMX_VPTS _IOR(VIDEOSYNC_IOC_MAGIC, 0x05, unsigned int)
#define VIDEOSYNC_IOC_GET_OMX_VERSION \
_IOR(VIDEOSYNC_IOC_MAGIC, 0x06, unsigned int)
#define VIDEOSYNC_IOC_SET_OMX_ZORDER \
_IOW(VIDEOSYNC_IOC_MAGIC, 0x07, unsigned int)
#define VIDEOSYNC_S_VF_RECEIVER_NAME_SIZE 32
#define VIDEOSYNC_S_POOL_SIZE 16
#define VIDEOSYNC_VF_NAME_SIZE 32
extern int videosync_assign_map(char **receiver_name, int *inst);
struct videosync_buffer_states {
int buf_ready_num;
int buf_queued_num;
int total_num;
};
struct videosync_operations_s {
struct vframe_s *(*peek)(void *op_arg);
struct vframe_s *(*get)(void *op_arg);
void (*put)(struct vframe_s *, void *op_arg);
int (*event_cb)(int type, void *data, void *private_data);
int (*buffer_states)(struct videosync_buffer_states *states,
void *op_arg);
};
struct display_area {
u32 left;
u32 top;
u32 width;
u32 height;
};
struct videosync_s {
void *dev;
int index;
int fd_num;
char vf_receiver_name[VIDEOSYNC_S_VF_RECEIVER_NAME_SIZE];
int inst;
bool mapped;
bool receiver_register;
struct vframe_receiver_s vp_vf_receiver;
struct vfq_s queued_q;
struct vfq_s ready_q;
struct vframe_s *videosync_pool_queued[VIDEOSYNC_S_POOL_SIZE + 1];
struct vframe_s *videosync_pool_ready[VIDEOSYNC_S_POOL_SIZE + 1];
int active_state;
const struct videosync_operations_s *ops;
struct completion inactive_done;
struct vframe_s *cur_dispbuf;
spinlock_t timestamp_lock;
struct mutex omx_mutex;
u32 system_time_up;
u32 system_time;
u32 system_time_scale_remainder;
u32 omx_pts;
u32 vpts_ref;
u32 video_frame_repeat_count;
u32 freerun_mode;
u32 first_frame_toggled;
u32 get_frame_count;
u32 put_frame_count;
void *op_arg;
char *name;
struct display_area rect;
u32 zorder;
struct vframe_provider_s video_vf_prov;
char vf_provider_name[VIDEOSYNC_VF_NAME_SIZE];
};
#endif

View File

@@ -6130,6 +6130,8 @@ static irqreturn_t vsync_isr_in(int irq, void *dev_id)
timestamp_pcrscr_inc_scale(vsync_pts_inc_scale,
vsync_pts_inc_scale_base);
timestamp_apts_inc(vsync_pts_inc / vsync_slow_factor);
videosync_pcrscr_update(vsync_pts_inc_scale,
vsync_pts_inc_scale_base);
} else if (vsync_slow_factor > 1000) {
u32 inc = (vsync_slow_factor / 1000)
* vsync_pts_inc / 1000;

View File

@@ -30,6 +30,7 @@
#define VFM_MAJOR (14+(AML_BASE))
#define IONVIDEO_MAJOR (15+(AML_BASE))
#define VAD_MAJOR (16+(AML_BASE))
#define VIDEOSYNC_MAJOR (17+(AML_BASE))
/*
*#define UIO_MAJOR 4+(AML_BASE)
*#define USB_DEV_EP_MAJOR 5+(AML_BASE)

View File

@@ -245,5 +245,5 @@ void set_video_angle(u32 s_value);
u32 get_video_angle(void);
extern unsigned int DI_POST_REG_RD(unsigned int addr);
extern int DI_POST_WR_REG_BITS(u32 adr, u32 val, u32 start, u32 len);
extern void videosync_pcrscr_update(s32 inc, u32 base);
#endif /* VIDEO_H */