• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18 #ifndef __DRV_HDMI_EVENT_H__
19 #define __DRV_HDMI_EVENT_H__
20 
21 #include "hi_type.h"
22 #include "drv_hdmi_common.h"
23 #include "hdmi_product_define.h"
24 
25 #define HDMI_EVENT_POOL_SIZE 10
26 #define HDMI_EVENT_ID_EXIST  0xff
27 #define HDMI_EVENT_POOL_CNT  10
28 
29 typedef struct {
30     hi_u32 hpd_rd_cnt;
31     hi_u32 hpd_wr_cnt;
32     hi_u32 unhpd_rd_cnt;
33     hi_u32 unhpd_wr_cnt;
34     hi_u32 edid_fail_rd_cnt;
35     hi_u32 edid_fail_wr_cnt;
36     hi_u32 rsen_con_rd_cnt;
37     hi_u32 rsen_con_wr_cnt;
38     hi_u32 rsen_dis_rd_cnt;
39     hi_u32 rsen_dis_wr_cnt;
40     hi_u32 err_rd_cnt;
41     hi_u32 err_wd_cnt;
42 } hdmi_event_run_cnt;
43 
44 typedef struct {
45     hi_u32     pool_id;
46     hi_bool    wakeup_flag;
47     hi_u32     readable_cnt;
48     hi_u32     read_ptr;
49     hi_u32     write_ptr;
50     hdmi_event event_pool[HDMI_EVENT_POOL_SIZE];
51 } hdmi_event_run_ctrl;
52 
53 typedef struct {
54     hdmi_event_run_cnt run_cnt;
55     hdmi_event_run_ctrl ctrl;
56 } hdmi_event_pool;
57 
58 typedef struct {
59     osal_semaphore_t event_mutex; /* lock to avoid competition */
60     osal_wait_t      wr_queue;    /* wait queue to wake up the sleeping process */
61     hi_bool          wakeup_all;  /* wakeup all pool flag */
62     hi_bool          init;        /* is the struct init */
63     hi_u32           total;       /* total pools in the list */
64     hdmi_event_pool  pool[HDMI_EVENT_POOL_CNT];
65     hdmi_event       event;
66 } hdmi_event_info;
67 
68 typedef struct {
69     hdmi_event_info *evt_info;
70     hdmi_event_pool *tmp_pool;
71 } hdmi_event_wait_callback;
72 
73 hi_s32 drv_hdmi_event_init(hdmi_device_id hdmi_id);
74 
75 hi_s32 drv_hdmi_event_deinit(hdmi_device_id hdmi_id);
76 
77 hi_s32 drv_hdmi_event_pool_malloc(hdmi_device_id hdmi_id, hi_u32 *pool_id);
78 
79 hi_s32 drv_hdmi_event_pool_free(hdmi_device_id hdmi_id, hi_u32 pool_id);
80 
81 hi_s32 drv_hdmi_event_pool_write(hdmi_device_id hdmi_id, hdmi_event event);
82 
83 hi_s32 drv_hdmi_event_pool_read(hdmi_device_id hdmi_id, hi_u32 pool_id, hdmi_event *event);
84 
85 hi_s32 drv_hdmi_event_pool_status_get(hdmi_device_id hdmi_id, hi_u32 pool_num,
86                                       hdmi_event_run_ctrl *ctrl, hdmi_event_run_cnt *cnt);
87 
88 hi_s32 drv_hdmi_event_pool_total_get(hdmi_device_id hdmi_id, hi_u32 *total);
89 
90 hi_s32 drv_hdmi_event_pool_id_get(hdmi_device_id hdmi_id, hi_u32 *thread_id);
91 
92 #endif  // __DRV_HDMI_EVENT_H__
93 
94