Song Zhao | ea5a041 | 2021-01-18 16:40:08 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 Amlogic, Inc. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | */ |
| 15 | #ifndef AML_MSYNC_H |
| 16 | #define AML_MSYNC_H |
| 17 | |
| 18 | #ifndef __KERNEL__ |
| 19 | #include <stdint.h> |
| 20 | #endif |
| 21 | |
| 22 | struct pts_tri { |
| 23 | uint32_t wall_clock; |
| 24 | uint32_t pts; |
| 25 | uint32_t delay; |
| 26 | }; |
| 27 | |
Song Zhao | d62bb39 | 2021-04-23 12:25:49 -0700 | [diff] [blame^] | 28 | struct pcr_pair { |
| 29 | uint32_t pts; |
| 30 | uint64_t mono_clock; |
| 31 | }; |
| 32 | |
Song Zhao | ea5a041 | 2021-01-18 16:40:08 -0800 | [diff] [blame] | 33 | struct pts_wall { |
| 34 | uint32_t wall_clock; |
| 35 | uint32_t interval; |
| 36 | }; |
| 37 | |
| 38 | enum av_sync_mode { |
| 39 | AVS_MODE_A_MASTER, |
| 40 | AVS_MODE_V_MASTER, |
| 41 | AVS_MODE_PCR_MASTER, |
| 42 | AVS_MODE_IPTV, |
| 43 | AVS_MODE_FREE_RUN |
| 44 | }; |
| 45 | |
| 46 | struct session_sync_stat { |
| 47 | uint32_t v_active; |
| 48 | uint32_t a_active; |
| 49 | /* enum av_sync_mode */ |
| 50 | uint32_t mode; |
Song Zhao | e208d69 | 2021-04-19 15:38:52 -0700 | [diff] [blame] | 51 | /* valid in aligned sync */ |
| 52 | uint32_t v_timeout; |
Song Zhao | ea5a041 | 2021-01-18 16:40:08 -0800 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | enum avs_event { |
| 56 | AVS_VIDEO_START, |
| 57 | AVS_PAUSE, |
| 58 | AVS_RESUME, |
| 59 | AVS_VIDEO_STOP, |
| 60 | AVS_AUDIO_STOP, |
| 61 | AVS_VIDEO_TSTAMP_DISCONTINUITY, |
| 62 | AVS_AUDIO_TSTAMP_DISCONTINUITY, |
| 63 | AVS_EVENT_MAX, |
| 64 | }; |
| 65 | |
| 66 | enum avs_astart_mode { |
| 67 | AVS_START_SYNC = 0, |
| 68 | AVS_START_ASYNC, |
Song Zhao | d62bb39 | 2021-04-23 12:25:49 -0700 | [diff] [blame^] | 69 | AVS_START_AGAIN, |
Song Zhao | ea5a041 | 2021-01-18 16:40:08 -0800 | [diff] [blame] | 70 | AVS_START_MAX |
| 71 | }; |
| 72 | |
| 73 | struct audio_start { |
| 74 | /* in first audio pts */ |
| 75 | uint32_t pts; |
| 76 | /* in render delay */ |
| 77 | uint32_t delay; |
| 78 | /* out enum avs_astart_mode */ |
| 79 | uint32_t mode; |
| 80 | }; |
| 81 | |
| 82 | struct session_event { |
| 83 | /* enum avs_event */ |
| 84 | uint32_t event; |
| 85 | uint32_t value; |
| 86 | }; |
| 87 | |
Song Zhao | d62bb39 | 2021-04-23 12:25:49 -0700 | [diff] [blame^] | 88 | struct session_debug { |
| 89 | uint32_t debug_freerun; |
| 90 | uint32_t pcr_init_flag; |
| 91 | uint32_t pcr_init_mode; |
| 92 | }; |
| 93 | |
Song Zhao | ea5a041 | 2021-01-18 16:40:08 -0800 | [diff] [blame] | 94 | #define AVS_INVALID_PTS 0xFFFFFFFFUL |
| 95 | |
| 96 | #define AMSYNC_START_V_FIRST 0x1 |
| 97 | #define AMSYNC_START_A_FIRST 0x2 |
| 98 | #define AMSYNC_START_ASAP 0x3 |
| 99 | #define AMSYNC_START_ALIGN 0x4 |
| 100 | |
| 101 | /* msync ioctl */ |
| 102 | #define _A_M_S 'M' |
| 103 | #define AMSYNC_IOC_ALLOC_SESSION _IOW((_A_M_S), 0x00, int) |
| 104 | #define AMSYNC_IOC_REMOVE_SESSION _IOR((_A_M_S), 0x01, int) |
| 105 | |
| 106 | /* session ioctl */ |
| 107 | #define _A_M_SS 'S' |
| 108 | #define AMSYNCS_IOC_SET_MODE _IOW((_A_M_SS), 0x00, unsigned int) |
| 109 | #define AMSYNCS_IOC_GET_MODE _IOR((_A_M_SS), 0x01, unsigned int) |
| 110 | #define AMSYNCS_IOC_SET_START_POLICY _IOW((_A_M_SS), 0x02, unsigned int) |
| 111 | #define AMSYNCS_IOC_GET_START_POLICY _IOR((_A_M_SS), 0x03, unsigned int) |
| 112 | #define AMSYNCS_IOC_SET_V_TS _IOW((_A_M_SS), 0x04, struct pts_tri) |
| 113 | #define AMSYNCS_IOC_GET_V_TS _IOWR((_A_M_SS), 0x05, struct pts_tri) |
| 114 | #define AMSYNCS_IOC_SET_A_TS _IOW((_A_M_SS), 0x06, struct pts_tri) |
| 115 | #define AMSYNCS_IOC_GET_A_TS _IOWR((_A_M_SS), 0x07, struct pts_tri) |
| 116 | #define AMSYNCS_IOC_SEND_EVENT _IOWR((_A_M_SS), 0x08, struct session_event) |
| 117 | //For PCR/IPTV mode only |
| 118 | #define AMSYNCS_IOC_GET_SYNC_STAT _IOWR((_A_M_SS), 0x09, struct session_sync_stat) |
Song Zhao | d62bb39 | 2021-04-23 12:25:49 -0700 | [diff] [blame^] | 119 | #define AMSYNCS_IOC_SET_PCR _IOW((_A_M_SS), 0x0a, struct pcr_pair) |
| 120 | #define AMSYNCS_IOC_GET_PCR _IOWR((_A_M_SS), 0x0b, struct pcr_pair) |
Song Zhao | ea5a041 | 2021-01-18 16:40:08 -0800 | [diff] [blame] | 121 | #define AMSYNCS_IOC_GET_WALL _IOR((_A_M_SS), 0x0c, struct pts_wall) |
| 122 | #define AMSYNCS_IOC_SET_RATE _IOW((_A_M_SS), 0x0d, unsigned int) |
| 123 | #define AMSYNCS_IOC_GET_RATE _IOR((_A_M_SS), 0x0e, unsigned int) |
| 124 | #define AMSYNCS_IOC_SET_NAME _IOR((_A_M_SS), 0x0f, char *) |
| 125 | #define AMSYNCS_IOC_SET_WALL_ADJ_THRES _IOW((_A_M_SS), 0x10, unsigned int) |
| 126 | #define AMSYNCS_IOC_GET_WALL_ADJ_THRES _IOR((_A_M_SS), 0x11, unsigned int) |
| 127 | #define AMSYNCS_IOC_GET_CLOCK_START _IOR((_A_M_SS), 0x12, unsigned int) |
| 128 | #define AMSYNCS_IOC_AUDIO_START _IOW((_A_M_SS), 0x13, struct audio_start) |
| 129 | |
Song Zhao | d62bb39 | 2021-04-23 12:25:49 -0700 | [diff] [blame^] | 130 | //For debuging |
| 131 | #define AMSYNCS_IOC_GET_DEBUG_MODE _IOR((_A_M_SS), 0x100, struct session_debug) |
| 132 | |
Song Zhao | ea5a041 | 2021-01-18 16:40:08 -0800 | [diff] [blame] | 133 | #endif |