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 | |
| 28 | struct pts_wall { |
| 29 | uint32_t wall_clock; |
| 30 | uint32_t interval; |
| 31 | }; |
| 32 | |
| 33 | enum av_sync_mode { |
| 34 | AVS_MODE_A_MASTER, |
| 35 | AVS_MODE_V_MASTER, |
| 36 | AVS_MODE_PCR_MASTER, |
| 37 | AVS_MODE_IPTV, |
| 38 | AVS_MODE_FREE_RUN |
| 39 | }; |
| 40 | |
| 41 | struct session_sync_stat { |
| 42 | uint32_t v_active; |
| 43 | uint32_t a_active; |
| 44 | /* enum av_sync_mode */ |
| 45 | uint32_t mode; |
| 46 | }; |
| 47 | |
| 48 | enum avs_event { |
| 49 | AVS_VIDEO_START, |
| 50 | AVS_PAUSE, |
| 51 | AVS_RESUME, |
| 52 | AVS_VIDEO_STOP, |
| 53 | AVS_AUDIO_STOP, |
| 54 | AVS_VIDEO_TSTAMP_DISCONTINUITY, |
| 55 | AVS_AUDIO_TSTAMP_DISCONTINUITY, |
| 56 | AVS_EVENT_MAX, |
| 57 | }; |
| 58 | |
| 59 | enum avs_astart_mode { |
| 60 | AVS_START_SYNC = 0, |
| 61 | AVS_START_ASYNC, |
| 62 | AVS_START_MAX |
| 63 | }; |
| 64 | |
| 65 | struct audio_start { |
| 66 | /* in first audio pts */ |
| 67 | uint32_t pts; |
| 68 | /* in render delay */ |
| 69 | uint32_t delay; |
| 70 | /* out enum avs_astart_mode */ |
| 71 | uint32_t mode; |
| 72 | }; |
| 73 | |
| 74 | struct session_event { |
| 75 | /* enum avs_event */ |
| 76 | uint32_t event; |
| 77 | uint32_t value; |
| 78 | }; |
| 79 | |
| 80 | #define AVS_INVALID_PTS 0xFFFFFFFFUL |
| 81 | |
| 82 | #define AMSYNC_START_V_FIRST 0x1 |
| 83 | #define AMSYNC_START_A_FIRST 0x2 |
| 84 | #define AMSYNC_START_ASAP 0x3 |
| 85 | #define AMSYNC_START_ALIGN 0x4 |
| 86 | |
| 87 | /* msync ioctl */ |
| 88 | #define _A_M_S 'M' |
| 89 | #define AMSYNC_IOC_ALLOC_SESSION _IOW((_A_M_S), 0x00, int) |
| 90 | #define AMSYNC_IOC_REMOVE_SESSION _IOR((_A_M_S), 0x01, int) |
| 91 | |
| 92 | /* session ioctl */ |
| 93 | #define _A_M_SS 'S' |
| 94 | #define AMSYNCS_IOC_SET_MODE _IOW((_A_M_SS), 0x00, unsigned int) |
| 95 | #define AMSYNCS_IOC_GET_MODE _IOR((_A_M_SS), 0x01, unsigned int) |
| 96 | #define AMSYNCS_IOC_SET_START_POLICY _IOW((_A_M_SS), 0x02, unsigned int) |
| 97 | #define AMSYNCS_IOC_GET_START_POLICY _IOR((_A_M_SS), 0x03, unsigned int) |
| 98 | #define AMSYNCS_IOC_SET_V_TS _IOW((_A_M_SS), 0x04, struct pts_tri) |
| 99 | #define AMSYNCS_IOC_GET_V_TS _IOWR((_A_M_SS), 0x05, struct pts_tri) |
| 100 | #define AMSYNCS_IOC_SET_A_TS _IOW((_A_M_SS), 0x06, struct pts_tri) |
| 101 | #define AMSYNCS_IOC_GET_A_TS _IOWR((_A_M_SS), 0x07, struct pts_tri) |
| 102 | #define AMSYNCS_IOC_SEND_EVENT _IOWR((_A_M_SS), 0x08, struct session_event) |
| 103 | //For PCR/IPTV mode only |
| 104 | #define AMSYNCS_IOC_GET_SYNC_STAT _IOWR((_A_M_SS), 0x09, struct session_sync_stat) |
| 105 | #define AMSYNCS_IOC_SET_PCR _IOW((_A_M_SS), 0x0a, unsigned int) |
| 106 | #define AMSYNCS_IOC_GET_PCR _IOWR((_A_M_SS), 0x0b, unsigned int) |
| 107 | #define AMSYNCS_IOC_GET_WALL _IOR((_A_M_SS), 0x0c, struct pts_wall) |
| 108 | #define AMSYNCS_IOC_SET_RATE _IOW((_A_M_SS), 0x0d, unsigned int) |
| 109 | #define AMSYNCS_IOC_GET_RATE _IOR((_A_M_SS), 0x0e, unsigned int) |
| 110 | #define AMSYNCS_IOC_SET_NAME _IOR((_A_M_SS), 0x0f, char *) |
| 111 | #define AMSYNCS_IOC_SET_WALL_ADJ_THRES _IOW((_A_M_SS), 0x10, unsigned int) |
| 112 | #define AMSYNCS_IOC_GET_WALL_ADJ_THRES _IOR((_A_M_SS), 0x11, unsigned int) |
| 113 | #define AMSYNCS_IOC_GET_CLOCK_START _IOR((_A_M_SS), 0x12, unsigned int) |
| 114 | #define AMSYNCS_IOC_AUDIO_START _IOW((_A_M_SS), 0x13, struct audio_start) |
| 115 | |
| 116 | #endif |