1 /* 2 * drivers/amlogic/media/frame_provider/decoder/utils/frame_check.h 3 * 4 * Copyright (C) 2016 Amlogic, Inc. All rights reserved. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 * more details. 15 * 16 */ 17 18 #ifndef __FRAME_CHECK_H__ 19 #define __FRAME_CHECK_H__ 20 21 22 #include <linux/fs.h> 23 #include <linux/uaccess.h> 24 #include <linux/amlogic/media/vfm/vframe.h> 25 #include <linux/kfifo.h> 26 27 #define FRAME_CHECK 28 29 #define YUV_MAX_DUMP_NUM 60 30 31 #define SIZE_CRC 64 32 #define SIZE_CHECK_Q 128 33 34 #define USER_CMP_POOL_MAX_SIZE (SIZE_CHECK_Q) 35 36 struct pic_dump_t{ 37 struct file *yuv_fp; 38 loff_t yuv_pos; 39 unsigned int start; 40 unsigned int num; 41 unsigned int end; 42 unsigned int dump_cnt; 43 44 unsigned int buf_size; 45 char *buf_addr; 46 }; 47 48 struct pic_check_t{ 49 struct file *check_fp; 50 loff_t check_pos; 51 52 struct file *compare_fp; 53 loff_t compare_pos; 54 unsigned int cmp_crc_cnt; 55 void *fbc_planes[4]; 56 void *check_addr; 57 DECLARE_KFIFO(new_chk_q, char *, SIZE_CHECK_Q); 58 DECLARE_KFIFO(wr_chk_q, char *, SIZE_CHECK_Q); 59 }; 60 61 struct pic_check_mgr_t{ 62 int id; 63 int enable; 64 unsigned int frame_cnt; 65 /* pic info */ 66 unsigned int canvas_w; 67 unsigned int canvas_h; 68 unsigned int size_y; //real size 69 unsigned int size_uv; 70 unsigned int size_pic; 71 unsigned int last_size_pic; 72 void *y_vaddr; 73 void *uv_vaddr; 74 ulong y_phyaddr; 75 ulong uv_phyaddr; 76 int err_crc_block; 77 78 int file_cnt; 79 atomic_t work_inited; 80 struct work_struct frame_check_work; 81 82 struct pic_check_t pic_check; 83 struct pic_dump_t pic_dump; 84 85 struct usr_crc_info_t *cmp_pool; 86 int usr_cmp_num; 87 int usr_cmp_result; 88 /* for mjpeg u different addr with v */ 89 bool mjpeg_flag; 90 void *extra_v_vaddr; 91 ulong extra_v_phyaddr; 92 }; 93 94 int dump_yuv_trig(struct pic_check_mgr_t *mgr, 95 int id, int start, int num); 96 97 int decoder_do_frame_check(struct vdec_s *vdec, struct vframe_s *vf); 98 99 int frame_check_init(struct pic_check_mgr_t *mgr, int id); 100 101 void frame_check_exit(struct pic_check_mgr_t *mgr); 102 103 ssize_t frame_check_show(struct class *class, 104 struct class_attribute *attr, char *buf); 105 106 ssize_t frame_check_store(struct class *class, 107 struct class_attribute *attr, 108 const char *buf, size_t size); 109 110 ssize_t dump_yuv_show(struct class *class, 111 struct class_attribute *attr, char *buf); 112 113 ssize_t dump_yuv_store(struct class *class, 114 struct class_attribute *attr, 115 const char *buf, size_t size); 116 117 void vdec_frame_check_exit(struct vdec_s *vdec); 118 int vdec_frame_check_init(struct vdec_s *vdec); 119 120 #endif /* __FRAME_CHECK_H__ */ 121 122