/* * amba_netlink.h * * History: * 2018/07/06 - [Zhaoyang Chen] created file * * Copyright (c) 2016 Ambarella, Inc. * * This file and its contents ("Software") are protected by intellectual * property rights including, without limitation, U.S. and/or foreign * copyrights. This Software is also the confidential and proprietary * information of Ambarella, Inc. and its licensors. You may not use, reproduce, * disclose, distribute, modify, or otherwise prepare derivative works of this * Software or any portion thereof except pursuant to a signed license agreement * or nondisclosure agreement with Ambarella, Inc. or its authorized affiliates. * In the absence of such an agreement, you agree to promptly notify and return * this Software to Ambarella, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, * MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL AMBARELLA, INC. OR ITS AFFILIATES BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; COMPUTER FAILURE OR MALFUNCTION; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ #ifndef ___AMBA_NL_H__ #define ___AMBA_NL_H__ #ifdef __cplusplus extern "C" { #endif #define AMBA_NL_MAX_MSG_LEN (1024) enum AMBA_NL_OBJ { AMBA_NL_OBJ_IMAGE = 0x00, AMBA_NL_OBJ_SYS = 0x01, AMBA_NL_OBJ_VP = 0x02, AMBA_NL_OBJ_ERROR = 0x03, AMBA_NL_OBJ_MAX_NUM = 0x04, }; enum AMBA_NL_MODULE { AMBA_NL_MODULE_DSP = 0x00, AMBA_NL_MODULE_VIN = 0x01, AMBA_NL_MODULE_IAV = 0x02, AMBA_NL_MODULE_IMG = 0x03, AMBA_NL_DEFINED_MODULE_NUM = 0x04, /* Pre-defined module num */ AMBA_NL_MODULE_MAX_NUM = 0xFF, /* Total supported module num */ AMBA_NL_MODULE_FIRST = AMBA_NL_MODULE_DSP, AMBA_NL_MODULE_CUSTOM_FIRST = AMBA_NL_DEFINED_MODULE_NUM, AMBA_NL_MODULE_LAST = AMBA_NL_MODULE_MAX_NUM, AMBA_NL_MODULE_INVALID = AMBA_NL_MODULE_MAX_NUM, }; enum AMBA_NL_PORT { AMBA_NL_PORT_BASE = 24, AMBA_NL_PORT_IMAGE = AMBA_NL_PORT_BASE + AMBA_NL_OBJ_IMAGE, AMBA_NL_PORT_SYS = AMBA_NL_PORT_BASE + AMBA_NL_OBJ_SYS, AMBA_NL_PORT_VP = AMBA_NL_PORT_BASE + AMBA_NL_OBJ_VP, AMBA_NL_PORT_ERROR = AMBA_NL_PORT_BASE + AMBA_NL_OBJ_ERROR, }; enum AMBA_NL_MSG_IMAGE { /* 0x18020000 */ AMBA_NL_MSG_IMG_START_AAA = ((AMBA_NL_PORT_IMAGE) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0000), /* 0x18020001 */ AMBA_NL_MSG_IMG_STOP_AAA = ((AMBA_NL_PORT_IMAGE) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0001), /* 0x18020002 */ AMBA_NL_MSG_IMG_PREPARE_AAA = ((AMBA_NL_PORT_IMAGE) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0002), /* 0x18020003 */ AMBA_NL_MSG_IMG_DPTZ_MAIN = ((AMBA_NL_PORT_IMAGE) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0003), /* 0x18020004 */ AMBA_NL_MSG_IMG_WARP = ((AMBA_NL_PORT_IMAGE) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0004), AMBA_NL_MSG_IMG_LAST = ((AMBA_NL_PORT_IMAGE) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0005), AMBA_NL_MSG_IMG_FIRST = AMBA_NL_MSG_IMG_START_AAA, }; enum AMBA_NL_MSG_SYS { /* 0x19020000 */ AMBA_NL_MSG_SYS_THAW_DONE = ((AMBA_NL_PORT_SYS) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0000), /* 0x19020001 */ AMBA_NL_MSG_SYS_IDLE = ((AMBA_NL_PORT_SYS) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0001), /* 0x19020002 */ AMBA_NL_MSG_SYS_PREVIEW = ((AMBA_NL_PORT_SYS) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0002), /* 0x19020003 */ AMBA_NL_MSG_SYS_ENCODE = ((AMBA_NL_PORT_SYS) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0003), AMBA_NL_MSG_SYS_LAST = ((AMBA_NL_PORT_SYS) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0004), AMBA_NL_MSG_SYS_FIRST = AMBA_NL_MSG_SYS_THAW_DONE, }; enum AMBA_NL_MSG_VP { /* 0x1A020000 */ AMBA_NL_MSG_VP_START_INFO = ((AMBA_NL_PORT_VP) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0000), AMBA_NL_MSG_VP_LAST = ((AMBA_NL_PORT_VP) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0001), AMBA_NL_MSG_VP_FIRST = AMBA_NL_MSG_VP_START_INFO, }; enum AMBA_NL_MSG_ERR_DSP { /* 0x1B000000: Failed to issue DSP cmd */ AMBA_NL_MSG_ERR_DSP_ISSUE_CMD = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_DSP) << 16 | 0x0000), /* 0x1B000001: DSP cmd num exceeds the limit */ AMBA_NL_MSG_ERR_DSP_CMD_EXCEED = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_DSP) << 16 | 0x0001), /* 0x1B000002: Invalide DSP cmd code */ AMBA_NL_MSG_ERR_DSP_CMD_CODE = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_DSP) << 16 | 0x0002), /* 0x1B000003: DSP triggers assertion */ AMBA_NL_MSG_ERR_DSP_ASSERTION = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_DSP) << 16 | 0x0003), AMBA_NL_MSG_ERR_DSP_LAST = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_DSP) << 16 | 0x0004), AMBA_NL_MSG_ERR_DSP_FIRST = AMBA_NL_MSG_ERR_DSP_ISSUE_CMD, }; enum AMBA_NL_MSG_ERR_VIN { /* 0x1B010000: Failed to apply VIN shutter/gain config */ AMBA_NL_MSG_ERR_VIN_APPLY_CFG = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_VIN) << 16 | 0x0000), /* 0x1B010001: Failed to switch context for current vin src */ AMBA_NL_MSG_ERR_VIN_SWITCH_CTX = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_VIN) << 16 | 0x0001), AMBA_NL_MSG_ERR_VIN_LAST = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_VIN) << 16 | 0x0002), AMBA_NL_MSG_ERR_VIN_FIRST = AMBA_NL_MSG_ERR_VIN_APPLY_CFG, }; enum AMBA_NL_MSG_ERR_IAV { /* 0x1B020000: Vsync lost signal from DSP */ AMBA_NL_MSG_ERR_IAV_VSYNC_LOST = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0000), /* 0x1B020001: Failed to sync frame sync cmd */ AMBA_NL_MSG_ERR_IAV_FRAME_SYNC = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0001), /* 0x1B020002: Failed to sync stream sync cmd */ AMBA_NL_MSG_ERR_IAV_STREAM_SYNC = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0002), /* 0x1B020003: Invalid DSP msg code */ AMBA_NL_MSG_ERR_IAV_MSG_CODE = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0003), /* 0x1B020004: Invalid stream ID from DSP msg */ AMBA_NL_MSG_ERR_IAV_STREAM_ID = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0004), /* 0x1B020005: Invalid stream state from DSP msg */ AMBA_NL_MSG_ERR_IAV_STREAM_STATE = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0005), AMBA_NL_MSG_ERR_IAV_LAST = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_IAV) << 16 | 0x0006), AMBA_NL_MSG_ERR_IAV_FIRST = AMBA_NL_MSG_ERR_IAV_VSYNC_LOST, }; enum AMBA_NL_MSG_ERR_IMG { /* 0x1B030000: Incorrect chan ID for the image statistics */ AMBA_NL_MSG_ERR_IMG_CHAN_ID = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_IMG) << 16 | 0x0000), /* 0x1B030001: DSP overwrites unread image statistics */ AMBA_NL_MSG_ERR_IMG_STATIS_OVERWRITE = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_IMG) << 16 | 0x0001), /* 0x1B030002: DSP sends out disordered image statistics */ AMBA_NL_MSG_ERR_IMG_STATIS_DISORDER = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_IMG) << 16 | 0x0002), /* 0x1B030003: Invalid slice num in image statistics from DSP */ AMBA_NL_MSG_ERR_IMG_STATIS_SLICE_NUM = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_IMG) << 16 | 0x0003), AMBA_NL_MSG_ERR_IMG_LAST = ((AMBA_NL_PORT_ERROR) << 24 | (AMBA_NL_MODULE_IMG) << 16 | 0x0004), AMBA_NL_MSG_ERR_IMG_FIRST = AMBA_NL_MSG_ERR_IMG_CHAN_ID, }; #define AMBA_NL_GET_MSG_PORT(msg) (((msg) >> 24) & 0xFF) #define AMBA_NL_GET_MSG_MODULE(msg) (((msg) >> 16) & 0xFF) #define AMBA_NL_GET_MSG_CODE(msg) ((msg) & 0xFFFF) enum AMBA_NL_MSG_SESSION { AMBA_NL_MSG_SESS_CONNECT = 0x00, AMBA_NL_MSG_SESS_DISCONNECT = 0x01, AMBA_NL_MSG_SESS_NUM = 0x02, AMBA_NL_MSG_SESS_FIRST = AMBA_NL_MSG_SESS_CONNECT, AMBA_NL_MSG_SESS_LAST = AMBA_NL_MSG_SESS_NUM, }; enum AMBA_NL_MSG_STATUS { AMBA_NL_MSG_STATUS_SUCCESS = 0x00, AMBA_NL_MSG_STATUS_FAIL = 0x01, AMBA_NL_MSG_STATUS_NUM = 0x02, AMBA_NL_MSG_STATUS_FIRST = AMBA_NL_MSG_STATUS_SUCCESS, AMBA_NL_MSG_STATUS_LAST = AMBA_NL_MSG_STATUS_NUM, }; enum AMBA_NL_MSG_TYPE { AMBA_NL_MSG_TYPE_SESSION = 0x00, AMBA_NL_MSG_TYPE_NORMAL = 0x01, AMBA_NL_MSG_TYPE_NUM = 0x02, AMBA_NL_MSG_TYPE_FIRST = AMBA_NL_MSG_TYPE_SESSION, AMBA_NL_MSG_TYPE_LAST = AMBA_NL_MSG_TYPE_NUM, }; enum AMBA_NL_MSG_DIR { AMBA_NL_MSG_DIR_MSG = 0x00, AMBA_NL_MSG_DIR_STATUS = 0x01, AMBA_NL_MSG_DIR_NUM = 0x02, AMBA_NL_MSG_DIR_FIRST = AMBA_NL_MSG_DIR_MSG, AMBA_NL_MSG_DIR_LAST = AMBA_NL_MSG_TYPE_NUM, }; #define AMBA_NL_MSG_SIZE (512) #define AMBA_NL_MSG_HEADER_SIZE (24) #define AMBA_NL_MSG_PAYLOAD_SIZE (AMBA_NL_MSG_SIZE - AMBA_NL_MSG_HEADER_SIZE) struct amba_nl_msg_vsync_data { u16 vinc_map; u16 reserved[3]; }; struct amba_nl_msg_data { u32 src_pid; /* The pid for the sender, 0 means kernel */ u32 dst_pid; /* The pid for the receiver, 0 means kernel */ u32 msg; /* The msg code */ u8 status; /* The status for the msg, if any */ u8 port; /* The netlink port for the msg */ u8 type; /* The msg type, session msg or normal msg */ u8 dir; /* The original msg or the status for the msg */ u64 hw_tick; /* The hw tick value from hw timer */ u8 payload[AMBA_NL_MSG_PAYLOAD_SIZE]; }; #ifdef __cplusplus } #endif #endif