#define FC_TST_DEBUG 0x80
#define FC_ERR_CRC_BLOCK_MODE 0x10
#define FC_CHECK_CRC_LOOP_MODE 0x20
+#define AD_CHECK_CRC_LOOP_MODE 0x40
#define YUV_MASK 0x01
#define CRC_MASK 0x02
+#define AUX_MASK 0x04
+
#define MAX_YUV_SIZE (4096 * 2304)
#define YUV_DEF_SIZE (MAX_YUV_SIZE * 3 / 2)
#define CRC_PATH "/data/tmp/"
#define YUV_PATH "/data/tmp/"
static char comp_crc[128] = "name";
+static char aux_comp_crc[128] = "aux";
static struct vdec_s *single_mode_vdec = NULL;
static unsigned int yuv_enable, check_enable;
+static unsigned int aux_enable;
static unsigned int yuv_start[MAX_INSTANCE_MUN];
static unsigned int yuv_num[MAX_INSTANCE_MUN];
p->enable &= (~mask);
}
+static inline void aux_set_enable(struct aux_data_check_mgr_t *p, int mask)
+{
+ p->enable |= mask;
+}
+
+static inline void aux_set_disable(struct aux_data_check_mgr_t *p, int mask)
+{
+ p->enable &= (~mask);
+}
+
+
static inline void check_schedule(struct pic_check_mgr_t *mgr)
{
if (atomic_read(&mgr->work_inited))
vdec_schedule_work(&mgr->frame_check_work);
}
+static inline void aux_data_check_schedule(struct aux_data_check_mgr_t *mgr)
+{
+ if (atomic_read(&mgr->work_inited))
+ vdec_schedule_work(&mgr->aux_data_check_work);
+}
+
static bool is_oversize(int w, int h)
{
if (w <= 0 || h <= 0)
return buf;
}
+static char *fget_aux_data_crc_str(char *buf,
+ unsigned int size, struct aux_data_check_t *fc)
+{
+ unsigned int c = 0, sz, ret, index, crc;
+ mm_segment_t old_fs;
+ char *cs;
+
+ if (!fc->compare_fp)
+ return NULL;
+
+ old_fs = get_fs();
+ set_fs(KERNEL_DS);
+
+ do {
+ cs = buf;
+ sz = size;
+ while (--sz && (c = vfs_read(fc->compare_fp,
+ cs, 1, &fc->compare_pos) != 0)) {
+ if (*cs++ == '\n')
+ break;
+ }
+ *cs = '\0';
+ if ((c == 0) && (cs == buf)) {
+ set_fs(old_fs);
+ return NULL;
+ }
+ ret = sscanf(buf, "%08u: %8x", &index, &crc);
+ dbg_print(FC_CRC_DEBUG, "%s, index = %d, cmp = %d\n",
+ __func__, index, fc->cmp_crc_cnt);
+ }while(ret != 2 || index != fc->cmp_crc_cnt);
+
+ set_fs(old_fs);
+ fc->cmp_crc_cnt++;
+
+ return buf;
+}
+
+
static struct file* file_open(int mode, const char *str, ...)
{
char file[256] = {0};
return 0;
}
+
+static int write_aux_data_crc_work(struct aux_data_check_mgr_t *mgr)
+{
+ unsigned int wr_size;
+ char *crc_buf, crc_tmp[64*30];
+ mm_segment_t old_fs;
+ struct aux_data_check_t *check = &mgr->aux_data_check;
+
+ if (mgr->enable & AUX_MASK) {
+ wr_size = 0;
+ while (kfifo_get(&check->wr_chk_q, &crc_buf) != 0) {
+ wr_size += sprintf(&crc_tmp[wr_size], "%s", crc_buf);
+ if (check->compare_fp != NULL) {
+ if (!fget_aux_data_crc_str(crc_buf, SIZE_CRC, check)) {
+ dbg_print(0, "%s, can't get more compare crc\n", __func__);
+ filp_close(check->compare_fp, current->files);
+ check->compare_fp = NULL;
+ }
+ }
+ kfifo_put(&check->new_chk_q, crc_buf);
+ }
+ if (check->check_fp && (wr_size != 0)) {
+ old_fs = get_fs();
+ set_fs(KERNEL_DS);
+ if (wr_size != vfs_write(check->check_fp,
+ crc_tmp, wr_size, &check->check_pos)) {
+ dbg_print(FC_ERROR, "failed to check_dump_filp\n");
+ }
+ set_fs(old_fs);
+ }
+ }
+ return 0;
+}
+
+
+
static void do_check_work(struct work_struct *work)
{
struct pic_check_mgr_t *mgr = container_of(work,
write_crc_work(mgr);
}
+static void do_aux_data_check_work(struct work_struct *work)
+{
+ struct aux_data_check_mgr_t *mgr = container_of(work,
+ struct aux_data_check_mgr_t, aux_data_check_work);
+
+ write_aux_data_crc_work(mgr);
+}
+
+
static int memcpy_phy_to_virt(char *to_virt,
ulong phy_from, unsigned int size)
{
return ret;
}
+static int aux_data_crc_store(struct aux_data_check_mgr_t *mgr,int crc)
+{
+ int ret = 0;
+ char *crc_addr = NULL;
+ int comp_frame = 0, comp_crc;
+ struct aux_data_check_t *check = &mgr->aux_data_check;
+
+ if (kfifo_get(&check->new_chk_q, &crc_addr) == 0) {
+ dbg_print(0, "%08d: %08x\n",
+ mgr->frame_cnt, crc);
+ if (check->check_fp) {
+ dbg_print(0, "crc32 dropped\n");
+ } else {
+ dbg_print(0, "no opened file to write crc32\n");
+ }
+ return -1;
+ }
+ if (check->cmp_crc_cnt > mgr->frame_cnt) {
+ sscanf(crc_addr, "%08u: %8x",
+ &comp_frame, &comp_crc);
+
+ dbg_print(0, "%08d: %08x <--> %08d: %08x\n",
+ mgr->frame_cnt, crc,
+ comp_frame, comp_crc);
+ if (comp_frame == mgr->frame_cnt) {
+ if (comp_crc != crc) {
+ dbg_print(0, "\n\nError: %08d: %08x != %08x \n\n",
+ mgr->frame_cnt, crc, comp_crc);
+ }
+ } else {
+ dbg_print(0, "frame num error: frame_cnt(%d) frame_comp(%d)\n",
+ mgr->frame_cnt, comp_frame);
+ }
+ } else {
+ dbg_print(0, "%08d: %08x\n", mgr->frame_cnt, crc);
+ }
+
+ if ((check->check_fp) && (crc_addr != NULL)) {
+ ret = snprintf(crc_addr, SIZE_CRC,
+ "%08d: %08x\n", mgr->frame_cnt, crc);
+
+ kfifo_put(&check->wr_chk_q, crc_addr);
+ if ((mgr->frame_cnt & 0xf) == 0)
+ aux_data_check_schedule(mgr);
+ }
+ return ret;
+}
+
+
static int crc32_vmap_le(unsigned int *crc32,
ulong phyaddr, unsigned int size)
return 0;
}
+static int do_check_aux_data_crc(struct aux_data_check_mgr_t *mgr,
+ char *aux_buf, int size)
+{
+ unsigned int crc = 0;
+
+ crc = crc32_le(0, aux_buf, size);
+
+ //pr_info("%s:crc = %08x\n",crc);
+ aux_data_crc_store(mgr,crc);
+
+ return 0;
+}
+
+
static int fbc_check_prepare(struct pic_check_t *check,
int resize, int y_size)
{
}
EXPORT_SYMBOL(decoder_do_frame_check);
+int decoder_do_aux_data_check(struct vdec_s *vdec, char *aux_buffer, int size)
+{
+ struct aux_data_check_mgr_t *mgr = NULL;
+ int ret = 0;
+
+ if (vdec == NULL) {
+ return 0;
+ } else {
+ mgr = &vdec->adc;
+ }
+
+ if ((mgr == NULL) || (mgr->enable == 0))
+ return 0;
+
+ if (mgr->enable & AUX_MASK)
+ ret = do_check_aux_data_crc(mgr,aux_buffer,size);
+
+ mgr->frame_cnt++;
+
+ return ret;
+}
+EXPORT_SYMBOL(decoder_do_aux_data_check);
+
static int dump_buf_alloc(struct pic_dump_t *dump)
{
if ((dump->buf_addr != NULL) &&
return 0;
}
+
+int aux_data_check_init(struct aux_data_check_mgr_t *mgr, int id)
+{
+ int i;
+ struct aux_data_check_t *check = &mgr->aux_data_check;
+
+ mgr->frame_cnt = 0;
+ mgr->id = id;
+
+ check->check_pos = 0;
+ check->compare_pos = 0;
+
+ if (!atomic_read(&mgr->work_inited)) {
+ INIT_WORK(&mgr->aux_data_check_work, do_aux_data_check_work);
+ atomic_set(&mgr->work_inited, 1);
+ }
+
+ /* try to open compare meta crc32 file */
+ str_strip(aux_comp_crc);
+ check->compare_fp = file_open(O_RDONLY,
+ "%s%s", CRC_PATH, aux_comp_crc);
+
+ /* create meta crc log file */
+ check->check_fp = file_open(O_CREAT| O_WRONLY | O_TRUNC,
+ "%s%s-%d-%d.crc", CRC_PATH, aux_comp_crc, id, mgr->file_cnt);
+
+ INIT_KFIFO(check->new_chk_q);
+ INIT_KFIFO(check->wr_chk_q);
+ check->check_addr = vmalloc(SIZE_CRC * SIZE_CHECK_Q);
+ if (check->check_addr == NULL) {
+ dbg_print(FC_ERROR, "vmalloc qbuf fail\n");
+ } else {
+ void *qaddr = NULL, *rdret = NULL;
+ check->cmp_crc_cnt = 0;
+ for (i = 0; i < SIZE_CHECK_Q; i++) {
+ qaddr = check->check_addr + i * SIZE_CRC;
+ rdret = fget_aux_data_crc_str(qaddr,
+ SIZE_CRC, check);
+ if (rdret == NULL) {
+ if (i < 3)
+ dbg_print(0, "can't get compare crc string\n");
+ if (check->compare_fp) {
+ filp_close(check->compare_fp, current->files);
+ check->compare_fp = NULL;
+ }
+ }
+
+ kfifo_put(&check->new_chk_q, qaddr);
+ }
+ }
+ aux_set_enable(mgr, AUX_MASK);
+ dbg_print(0, "%s end\n", __func__);
+
+ return 0;
+}
+
+
void frame_check_exit(struct pic_check_mgr_t *mgr)
{
int i;
}
}
+void aux_data_check_exit(struct aux_data_check_mgr_t *mgr)
+{
+ //struct pic_dump_t *dump = &mgr->pic_dump;
+ struct aux_data_check_t *check = &mgr->aux_data_check;
+
+ if (mgr->enable != 0) {
+ if (atomic_read(&mgr->work_inited)) {
+ cancel_work_sync(&mgr->aux_data_check_work);
+ atomic_set(&mgr->work_inited, 0);
+ }
+
+ write_aux_data_crc_work(mgr);
+
+ if (check->check_addr) {
+ vfree(check->check_addr);
+ check->check_addr = NULL;
+ }
+
+ if (check->check_fp) {
+ filp_close(check->check_fp, current->files);
+ check->check_fp = NULL;
+ }
+ if (check->compare_fp) {
+ filp_close(check->compare_fp, current->files);
+ check->compare_fp = NULL;
+ }
+
+ mgr->file_cnt++;
+ aux_set_disable(mgr, AUX_MASK);
+ dbg_print(0, "%s end\n", __func__);
+ }
+}
+
+
int vdec_frame_check_init(struct vdec_s *vdec)
{
return 0;
}
+int vdec_aux_data_check_init(struct vdec_s *vdec)
+{
+ int ret = 0, id = 0;
+
+ if (vdec == NULL)
+ return 0;
+
+ if ((vdec->is_reset) &&
+ (get_cpu_major_id() != AM_MESON_CPU_MAJOR_ID_GXL))
+ return 0;
+
+ if (!aux_enable)
+ return 0;
+
+ id = vdec->id;
+
+ if (aux_enable & (0x01 << id)) {
+ aux_data_check_init(&vdec->adc, id);
+ /*repeat check one video meta crc32, not clear enable*/
+ if ((fc_debug & AD_CHECK_CRC_LOOP_MODE) == 0)
+ aux_enable &= ~(0x01 << id);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(vdec_aux_data_check_init);
+
+
+void vdec_aux_data_check_exit(struct vdec_s *vdec)
+{
+ if (vdec == NULL)
+ return;
+ aux_data_check_exit(&vdec->adc);
+}
+EXPORT_SYMBOL(vdec_aux_data_check_exit);
+
+
void vdec_frame_check_exit(struct vdec_s *vdec)
{
if (vdec == NULL)
module_param_string(comp_crc, comp_crc, 128, 0664);
MODULE_PARM_DESC(comp_crc, "\n crc_filename\n");
+module_param_string(aux_comp_crc, aux_comp_crc, 128, 0664);
+MODULE_PARM_DESC(aux_comp_crc, "\n aux crc_filename\n");
+
+
module_param(fc_debug, uint, 0664);
MODULE_PARM_DESC(fc_debug, "\n frame check debug\n");
+module_param(aux_enable, uint, 0664);
+MODULE_PARM_DESC(aux_enable, "\n aux data check debug\n");
+
module_param(size_yuv_buf, uint, 0664);
MODULE_PARM_DESC(size_yuv_buf, "\n size_yuv_buf\n");