Skip to content

Commit

Permalink
Merge pull request #93 from aws-samples/c302_update
Browse files Browse the repository at this point in the history
Amlogic C302 BSP update
  • Loading branch information
codingspirit authored Jan 6, 2023
2 parents 0c2cee3 + 696ab36 commit aaea778
Show file tree
Hide file tree
Showing 19 changed files with 181 additions and 108 deletions.
78 changes: 50 additions & 28 deletions 3rdparty/C302/include/ipc_cfg_api.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/*
* Copyright (C) 2019-2024 Amlogic, Inc. All rights reserved.
*
* All information contained herein is Amlogic confidential.
*
* This software is provided to you pursuant to Software License Agreement
* (SLA) with Amlogic Inc ("Amlogic"). This software may be used
* only in accordance with the terms of this agreement.
*
* Redistribution and use in source and binary forms, with or without
* modification is strictly prohibited without prior written permission from
* Amlogic.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS 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; 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 __IPC_CFG_API_H__
#define __IPC_CFG_API_H__

Expand All @@ -19,16 +45,18 @@ typedef enum IPC_CFG_VI_OPTIONS
CFG_VI_OPTION_SNS_TYPE = 0,
CFG_VI_OPTION_FPS_MODE,
CFG_VI_OPTION_INPUT_LANE,
CFG_VI_OPTION_BUS_ID,
CFG_VI_OPTION_BUTT
} IPC_CFG_VI_OPTIONS;

typedef enum IPC_CFG_STREAM_OPTIONS
{
CFG_STREAM_OPTION_VIID = 0,
CFG_STREAM_OPTION_ISPID,
CFG_STREAM_OPTION_PPUID,
CFG_STREAM_OPTION_RESOLUTION,
CFG_STREAM_OPTION_FORMAT,
CFG_STREAM_OPTION_ENCODEC,
CFG_STREAM_OPTION_DUMP,
CFG_STREAM_OPTION_FRAMERATE,
CFG_STREAM_OPTION_PROFILE,
CFG_STREAM_OPTION_GOP,
Expand Down Expand Up @@ -67,6 +95,7 @@ typedef enum IPC_CFG_IMAGE_OPTIONS
CFG_IMAGE_OPTION_IRCUT,
CFG_IMAGE_OPTION_D2N,
CFG_IMAGE_OPTION_N2D,
CFG_IMAGE_OPTION_FLICKER,
CFG_IMAGE_OPTION_BUTT
} IPC_CFG_IMAGE_OPTIONS;

Expand All @@ -78,7 +107,7 @@ typedef enum IPC_CFG_AI_OPTIONS
CFG_AI_OPTION_SAMPLERATE,
CFG_AI_OPTION_BITWIDTH,
CFG_AI_OPTION_VOLUME,
//CFG_AI_OPTION_VQEENABLE,
CFG_AI_OPTION_VQEENABLE,
CFG_AI_OPTION_BUTT,
} IPC_CFG_AI_OPTIONS;

Expand All @@ -93,13 +122,6 @@ typedef enum IPC_CFG_AO_OPTIONS
CFG_AO_OPTION_BUTT,
} IPC_CFG_AO_OPTIONS;


typedef enum IPC_PARAM_RESTORE
{
PARAM_SIMPLE_RECOVERY = 0,
PARAM_FULL_RECOVERY
} IPC_PARAM_RESTORE;

typedef enum IPC_PARAM_ID
{
PARAM_VIDEO_ID = 0,
Expand All @@ -120,15 +142,15 @@ typedef enum IPC_PARAM_VIDEO_ID
/*********************************************************************************
*Function : IPC_CFG_GetOptions
*
*Description: Get parameters's information, such as setting range
*Description: Obtain detailed information of parameters such as settable range
*
*Param : #[in] s32Chn, Channel number (parameters with channel concept are valid)
* #[in] enParamId, Parameter ID (used to distinguish the obtained parameter categories)
* #[in] s32SubId, Parameter SubID (some parameters have multiple subtypes)
* #[in/out] pOptions, Parameter details obtained
*Param : #[in] s32Chn Channel number (parameters with channel concept are valid)
* #[in] enParamId Parameter ID (used to distinguish the obtained parameter categories)
* #[in] s32SubId Parameter ID (some parameters have multiple sub types) Example:IPC_PARAM_VIDEO_ID
* #[in/out] pOptions Parameter details obtained
*
*Return : =0, success
* =Other, fail
*Return : =0 Success
* =Other Failed
*********************************************************************************/
int IPC_CFG_GetOptions(int s32Chn, IPC_PARAM_ID enParamId, int s32SubId, IPC_CFG_OPTIONS **pOptions);

Expand All @@ -137,13 +159,13 @@ int IPC_CFG_GetOptions(int s32Chn, IPC_PARAM_ID enParamId, int s32SubId, IPC_CFG
*
*Description: Get parameters
*
*Param : #[in] s32Chn, Channel number (parameters with channel concept are valid)
* #[in] enParamId, Parameter ID (used to distinguish the obtained parameter categories)
* #[in] s32SubId, Parameter SubID (some parameters have multiple subtypes)
* #[in/out] pConfig, Obtained parameter (cannot be NULL)
*Param : #[in] s32Chn Channel number (parameters with channel concept are valid)
* #[in] enParamId Parameter ID (used to distinguish the obtained parameter categories)
* #[in] s32SubId Parameter ID (some parameters have multiple sub types) Example:IPC_PARAM_VIDEO_ID
* #[in/out] pConfig Obtained parameter (cannot be NULL)
*
*Return : =0, success
* =Other, fail
*Return : =0 Success
* =Other Failed
*********************************************************************************/
int IPC_CFG_GetParam(int s32Chn, IPC_PARAM_ID enParamId, int s32SubId, void *pConfig);

Expand All @@ -154,13 +176,13 @@ int IPC_CFG_CheckParam(int s32Chn, IPC_PARAM_ID enParamId, int s32SubId, void *p
*
*Description: Set parameters
*
*Param : #[in] s32Chn, Channel number (parameters with channel concept are valid)
* #[in] enParamId, Parameter ID (used to distinguish the obtained parameter categories)
* #[in] s32SubId, Parameter SubID (some parameters have multiple subtypes)
* #[in] pConfig, Set parameter (cannot be NULL)
*Param : #[in] s32Chn Channel number (parameters with channel concept are valid)
* #[in] enParamId Parameter ID (used to distinguish the obtained parameter categories)
* #[in] s32SubId Parameter ID (some parameters have multiple sub types) Example:IPC_PARAM_VIDEO_ID
* #[in] pConfig Set parameter (cannot be NULL)
*
*Return : =0, success
* =Other, fail
*Return : =0 Success
* =Other Failed
*********************************************************************************/
int IPC_CFG_SetParam(int s32Chn, IPC_PARAM_ID enParamId, int s32SubId, void *pConfig);

Expand Down
75 changes: 40 additions & 35 deletions 3rdparty/C302/include/ipc_cfg_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ extern "C" {
#define CHN_STREMA_NUM 1

#define MAX_STREAM_NUM (MAX_SENSOR_NUM * CHN_STREMA_NUM)
//#define MAX_CAPTURE_NUM (MAX_SENSOR_NUM * 1)
//#define MAX_VENC_NUM (MAX_STREAM_NUM + MAX_CAPTURE_NUM)

#define STR_COMM_LENGTH8 8
#define STR_COMM_LENGTH16 16
Expand All @@ -28,6 +26,8 @@ extern "C" {
#define MAX_CFG_NUM 64
#define MAX_CFG_AREA_NUM 4

#define EACH_VI_MAX_ISP_CHN 3
#define CALU_ISP_CHN_BY_VI(vi, ppu) ((vi*EACH_VI_MAX_ISP_CHN)+ppu) // Each sensor has 3 physical channels

typedef enum IPC_CFG_DATA_TYPE
{
Expand Down Expand Up @@ -78,7 +78,9 @@ typedef struct IPC_CFG_OPTIONS_ARRAY

typedef enum IPC_FRAMERATE_MODE
{
FRAMERATE_MODE_15 = 0,
FRAMERATE_MODE_10 = 0,
FRAMERATE_MODE_15,
FRAMERATE_MODE_20,
FRAMERATE_MODE_25,
FRAMERATE_MODE_30,
FRAMERATE_MODE_50,
Expand Down Expand Up @@ -186,43 +188,45 @@ typedef struct IPC_VI_CONFIG
char szSnsType[STR_COMM_LENGTH16]; // sensor type
IPC_FRAMERATE_MODE enFramerate; // input framerate mode
IPC_INPUT_LANE enInputLane; // input lane
int s32BusId; // I2C id
} IPC_VI_CONFIG;

/* video encode stream */
typedef struct IPC_STREAM_CONFIG
{
int s32ViId;
int s32IspId;
int s32PpuId;
IPC_RESOLUTION enResolution; // resolution
IPC_VFORMAT_TYPE enFormat; // 0-need encode,1-NV21
IPC_VFORMAT_TYPE enFormat; // stream format,0-need encode,1-not need encode,raw NV21
IPC_VCODEC_TYPE enCodec; // encode type
unsigned int u32Dump; // save continuous frames,default 0 not save,max=300
unsigned int u32Framerate; // framerate
unsigned int u32Profile; // H.264:0-baseline, 1-MP, 2-HP 3-SVC-T; H.265:0-MP, 1-Main; Jpege/MJpege:0-baseline
unsigned int u32H26xGop; // H264 H265 Gop
IPC_GOP_MODE enGopMode; // Gop mode
IPC_RC enRcMode; // RC mode
unsigned int u32Bitrate; // CBR QVBR(TargetBitRate) valid
unsigned int u32MaxBitrate; // VBR AVBR CVBR(&LongTermMaxBitrate) valid
unsigned int u32MinBitrate; // CVBR(LongTermMinBitrate) valid
unsigned int u32IQp; // H26X FIXQP valid
unsigned int u32PQp; // H26X FIXQP valid
unsigned int u32BQp; // H26X FIXQP valid
unsigned int u32QpMapMode; // H265 QPMAP valid
unsigned int u32Quality; // MJPEG valid
unsigned int u32Bitrate; // CBR QVBR(TargetBitRate) effective
unsigned int u32MaxBitrate; // VBR AVBR CVBR(&LongTermMaxBitrate) effective
unsigned int u32MinBitrate; // CVBR(LongTermMinBitrate) effective
unsigned int u32IQp; // H26X FIXQP effective
unsigned int u32PQp; // H26X FIXQP effective
unsigned int u32BQp; // H26X FIXQP effective
unsigned int u32QpMapMode; // H265 QPMAP effective
unsigned int u32Quality; // MJPEG effective
} IPC_STREAM_CONFIG;

/* 图像 */
/* image */
typedef struct IPC_IMAGE_CONFIG
{
unsigned char u8Flip; // 0-not flip, 1-flip
unsigned char u8Mirror; // 0-not mirror, 1-mirror
unsigned char u8Flip; // flip: 0-not flip 1-flip
unsigned char u8Mirror; // mirror: 0-not mirror 1-mirror
unsigned char u8ExpMode; // exposure mode: 0-Auto(slow shutter) 1-Auto(fix frame) 2-Manual
unsigned char u8WbMode; // whitebalance mode: 0-Manual 1-Auto
unsigned int u32ExpTime; // manual exposure time
unsigned int u32ExpDGain; // manual isp digital gain
unsigned char u8RGain; // manual wb red gain
unsigned char u8BGain; // manual wb green gain
unsigned char u8Denoise3d; // 3D noise reduction
unsigned int u32ExpDGain; // manual ISP digital gain
unsigned char u8RGain; // manual whitebalance red gain
unsigned char u8BGain; // manual whitebalance blue gain
unsigned char u8Denoise3d; // 3D denoise
unsigned char u8Brightness; // brightness
unsigned char u8Saturation; // saturation
unsigned char u8Contrast; // contrast
Expand All @@ -232,45 +236,46 @@ typedef struct IPC_IMAGE_CONFIG
unsigned char u8LDC; // distortion correction
unsigned char u8HLC; // strong light suppression
IPC_IRCUT_TYPE enIrcutType; // IRCUT type
unsigned int u32DayToNight; // time for day to night(timing mode valid)
unsigned int u32NightToDay; // time for night to day(timing mode valid)
unsigned int u32DayToNight; // day to night time, valid only in timed mode
unsigned int u32NightToDay; // night to day time, valid only in timed mode
unsigned char u8AntiFlickerMode; // antiflicker mode: 0-disable 1-50hz 2-60hz 3-Auto
} IPC_IMAGE_CONFIG;

typedef struct IPC_VIDEO_CONFIG
{
int s32SensorNum; // sensor number
int s32StreamNum; // video stream number
IPC_VI_CONFIG stViCfg[MAX_SENSOR_NUM]; // video input
IPC_STREAM_CONFIG stStreamCfg[MAX_STREAM_NUM]; // video encode stream
IPC_IMAGE_CONFIG stImageCfg[MAX_SENSOR_NUM]; // image parameters
IPC_STREAM_CONFIG stStreamCfg[MAX_STREAM_NUM]; // encoded stream
IPC_IMAGE_CONFIG stImageCfg[MAX_SENSOR_NUM]; // image
} IPC_VIDEO_CONFIG;
/*---------------------------------video parameters end--------------------------------*/
/*---------------------------------video parameters END--------------------------------*/

/*----------------------------------audio parameters----------------------------------*/
/* audio input */
typedef struct IPC_AI_CONFIG
{
unsigned int u32Enabled; // enabled
IPC_ACODEC_TYPE enCodec; // encode type
unsigned int u32Channels; // channel number
unsigned int u32Enabled; // enabled, 0-disabled, 1-enabled
IPC_ACODEC_TYPE enCodec; // codec type
unsigned int u32Channels; // channel
IPC_AUDIO_SAMPLERATE enSampleRate; // samplerate
IPC_AUDIO_BITWIDTH enBitWidth; // bit width
IPC_AUDIO_BITWIDTH enBitWidth; // bitwidth
unsigned int u32Volume; // volume
//unsigned int u32VqeEnable;
unsigned int u32VqeEnable; // VQE enable, 0-disabled, 1-enabled
} IPC_AI_CONFIG;

/* audio output */
typedef struct IPC_AO_CONFIG
{
unsigned int u32Enabled; // enabled
IPC_ACODEC_TYPE enCodec; // encode type
unsigned int u32Channels; // channel number
unsigned int u32Enabled; // enabled, 0-disabled, 1-enabled
IPC_ACODEC_TYPE enCodec; // codec type
unsigned int u32Channels; // channel
IPC_AUDIO_SAMPLERATE enSampleRate; // samplerate
IPC_AUDIO_BITWIDTH enBitWidth; // bit width
IPC_AUDIO_BITWIDTH enBitWidth; // bitwidth
unsigned int u32Volume; // volume
} IPC_AO_CONFIG;

/*--------------------------------audio parameters end---------------------------------*/
/*--------------------------------audio parameters END---------------------------------*/

int IPC_CFG_CheckCfgDir();
int IPC_CFG_CopyFile(char *pBackFile, char *pCfgFile);
Expand Down
5 changes: 4 additions & 1 deletion 3rdparty/C302/include/ipc_media_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extern "C" {
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
#include <pthread.h>

typedef enum IPC_MEDIA_FRAME_TYPE
{
Expand Down Expand Up @@ -44,14 +45,16 @@ typedef struct IPC_MEDIA_BUFFER
int s32EndOffset;
int s32DeadlineOffset;
pthread_mutex_t mutex;
pthread_cond_t cond;
//pthread_cond_t cond;
} IPC_MEDIA_BUFFER;

int IPC_MEDIA_BUFFER_Empty(IPC_MEDIA_BUFFER *pmbuffer);
int IPC_MEDIA_BUFFER_Read(IPC_MEDIA_BUFFER *pmbuffer, void* pdata, unsigned int u32size,
unsigned int *u32len, unsigned long long *u64pts);
int IPC_MEDIA_BUFFER_Write(IPC_MEDIA_BUFFER *pmbuffer, IPC_MEDIA_FRAME_TYPE mft,
void* pdata, unsigned int u32len, unsigned long long u64pts);

void IPC_MEDIA_BUFFER_Clear(IPC_MEDIA_BUFFER *pmbuffer);
IPC_MEDIA_BUFFER *IPC_MEDIA_BUFFER_Init(int s32Size);
void IPC_MEDIA_BUFFER_UnInit(IPC_MEDIA_BUFFER *pmbuffer);

Expand Down
1 change: 1 addition & 0 deletions 3rdparty/C302/include/ipc_video_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ int IPC_VIDEO_SetStreamConfig(int nStreamId, IPC_VFORMAT_TYPE fmt, IPC_RESOLUTIO
IPC_VCODEC_TYPE codec, unsigned int framerate, unsigned int profile);

int IPC_VIDEO_ReqIFrame(int sStreamId);
int IPC_VIDEO_CheckFrame(int sStreamId);
int IPC_VIDEO_GetFrame(IPC_VIDEO_FRAME *pvframe, int sStreamId, unsigned int uYuvSize);

void IPC_VIDEO_UpdateIspAttr();
Expand Down
Loading

0 comments on commit aaea778

Please sign in to comment.