Skip to content

Commit

Permalink
Updated XMA code merged from git enterprise
Browse files Browse the repository at this point in the history
  • Loading branch information
sarab96 committed Sep 21, 2018
1 parent 43f1349 commit 5352d1a
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 27 deletions.
1 change: 0 additions & 1 deletion src/xma/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ add_compile_options("-fPIC")
add_compile_options("-Wall" "-Werror")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DXMA_RES_TEST -DXMA_DEBUG")

#Uncomment when dep xml2 yaml are installed
add_subdirectory(src)

set (CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic")
Expand Down
11 changes: 8 additions & 3 deletions src/xma/include/app/xmabuffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef _XMA_BUFFERS_H_
#define _XMA_BUFFERS_H_

#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "lib/xmalimits.h"
Expand Down Expand Up @@ -95,12 +96,14 @@ typedef enum XmaBufferType
/**
* @struct XmaBufferRef
* Reference counted buffer used in XmaFrame and XmaDataBuffer
*
*/
typedef struct XmaBufferRef
{
int32_t refcount; /**< references to buffer */
XmaBufferType buffer_type; /**< location of buffer */
void *buffer; /**< data */
bool is_clone; /**< buffer member allocated externally */
} XmaBufferRef;

/**
Expand Down Expand Up @@ -212,9 +215,9 @@ xma_frame_from_buffers_clone(XmaFrameProperties *frame_props,
*
* @param frame frame instance to free
*
* @todo frame contains buffer pointers that are not freed. Consider
* freeing or adding flag to arg list to indicate that they should
* be freed. Operation is also not atomic and not thread safe.
* @note: A buffer with is_clone flag set will not be freed
* by XMA when the refcount is == 0. Any XMA container with
* references to this buffer will be freed (e.g. XmaFrame), however.
*/
void
xma_frame_free(XmaFrame *frame);
Expand Down Expand Up @@ -246,6 +249,8 @@ xma_data_from_buffer_clone(uint8_t *data, size_t size);
*
* @param data structure to be freed
*
* @note: A buffer with is_clone flag set will not be freed
* by XMA when the refcount is == 0.
*/
void
xma_data_buffer_free(XmaDataBuffer *data);
Expand Down
5 changes: 5 additions & 0 deletions src/xma/include/app/xmadecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/

#include "app/xmabuffers.h"
#include "app/xmaparam.h"
#include "lib/xmalimits.h"

#ifdef __cplusplus
Expand Down Expand Up @@ -247,6 +248,10 @@ typedef struct XmaDecoderProperties
char hwvendor_string[MAX_VENDOR_NAME];
/** todo */
int32_t intraOnly;
/** array of kernel-specific custom initialization parameters */
XmaParameter *params;
/** count of custom parameters for port */
uint32_t param_cnt;
} XmaDecoderProperties;

/* Forward declaration */
Expand Down
6 changes: 6 additions & 0 deletions src/xma/include/app/xmaencoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/

#include "app/xmabuffers.h"
#include "app/xmaparam.h"
#include "lib/xmalimits.h"

#ifdef __cplusplus
Expand Down Expand Up @@ -284,7 +285,12 @@ typedef struct XmaEncoderProperties
/** aq_mode */
int32_t aq_mode;
int32_t minQP;
/** force property values to be accepted by encoder plugin */
int32_t force_param;
/** array of kernel-specific custom initialization parameters */
XmaParameter *params;
/** count of custom parameters for port */
uint32_t param_cnt;
} XmaEncoderProperties;

/* Forward declaration */
Expand Down
11 changes: 8 additions & 3 deletions src/xma/include/app/xmakernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,14 @@ typedef enum XmaKernelType
*/
typedef struct XmaKernelProperties
{
XmaKernelType hwkernel_type; /**< requested kernel type */
char hwvendor_string[MAX_VENDOR_NAME]; /**< requested vendor */
XmaParameter *param; /**< kernel-specific custom initialization parameters */
/** requested kernel type */
XmaKernelType hwkernel_type;
/** requested vendor */
char hwvendor_string[MAX_VENDOR_NAME];
/** array of kernel-specific custom initialization parameters */
XmaParameter *params;
/** count of custom parameters for port */
uint32_t param_cnt;
} XmaKernelProperties;
/**
* @}
Expand Down
28 changes: 20 additions & 8 deletions src/xma/include/app/xmascaler.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,26 @@ typedef struct XmaScalerSession XmaScalerSession;
*/
typedef struct XmaScalerProperties
{
XmaScalerType hwscaler_type; /**< specific filter function requested */
XmaSession *destination; /**< downstream kernel receiving data from this filter */
uint32_t max_dest_cnt; /**< maximum number of scaled outputs */
char hwvendor_string[MAX_VENDOR_NAME]; /**< specific vendor filter originated from */
int32_t num_outputs; /**< number of actual scaled outputs */
XmaScalerFilterProperties filter_coefficients; /**< application-specified filter coefficients */
XmaScalerInOutProperties input; /**< input properties */
XmaScalerInOutProperties output[MAX_SCALER_OUTPUTS]; /**< output properties array */
/** specific filter function requested */
XmaScalerType hwscaler_type;
/** downstream kernel receiving data from this filter */
XmaSession *destination;
/** maximum number of scaled outputs */
uint32_t max_dest_cnt;
/** specific vendor filter originated from */
char hwvendor_string[MAX_VENDOR_NAME];
/** number of actual scaled outputs */
int32_t num_outputs;
/** application-specified filter coefficients */
XmaScalerFilterProperties filter_coefficients;
/** input properties */
XmaScalerInOutProperties input;
/** output properties array */
XmaScalerInOutProperties output[MAX_SCALER_OUTPUTS];
/** array of kernel-specific custom initialization parameters */
XmaParameter *params;
/** count of custom parameters for port */
uint32_t param_cnt;
} XmaScalerProperties;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/xma/src/xmaapi/xmaapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "lib/xmahw_hal.h"
#include "lib/xmasignal.h"

#define XMA_CFG_DEFAULT "/etc/xma/xma_def_sys_cfg.yaml"
#define XMA_CFG_DEFAULT "/var/tmp/xma_cfg.yaml"
#define XMAAPI_MOD "xmaapi"

XmaSingleton *g_xma_singleton;
Expand Down
11 changes: 11 additions & 0 deletions src/xma/src/xmaapi/xmabuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ xma_frame_alloc(XmaFrameProperties *frame_props)
{
frame->data[i].refcount++;
frame->data[i].buffer_type = XMA_HOST_BUFFER_TYPE;
frame->data[i].is_clone = false;
// TODO: Get plane size for each plane
frame->data[i].buffer = malloc(frame_props->width *
frame_props->height);
Expand Down Expand Up @@ -80,6 +81,7 @@ xma_frame_from_buffers_clone(XmaFrameProperties *frame_props,
frame->data[i].refcount++;
frame->data[i].buffer_type = XMA_HOST_BUFFER_TYPE;
frame->data[i].buffer = frame_data->data[i];
frame->data[i].is_clone = true;
}

return frame;
Expand All @@ -100,6 +102,9 @@ xma_frame_free(XmaFrame *frame)
if (frame->data[0].refcount > 0)
return;

for (int32_t i = 0; i < num_planes && !frame->data[i].is_clone; i++)
free(frame->data[i].buffer);

free(frame);
}

Expand All @@ -113,6 +118,7 @@ xma_data_from_buffer_clone(uint8_t *data, size_t size)
memset(buffer, 0, sizeof(XmaDataBuffer));
buffer->data.refcount++;
buffer->data.buffer_type = XMA_HOST_BUFFER_TYPE;
buffer->data.is_clone = true;
buffer->data.buffer = data;
buffer->alloc_size = size;

Expand All @@ -128,6 +134,7 @@ xma_data_buffer_alloc(size_t size)
memset(buffer, 0, sizeof(XmaDataBuffer));
buffer->data.refcount++;
buffer->data.buffer_type = XMA_HOST_BUFFER_TYPE;
buffer->data.is_clone = false;
buffer->data.buffer = malloc(size);
buffer->alloc_size = size;

Expand All @@ -142,6 +149,10 @@ xma_data_buffer_free(XmaDataBuffer *data)
data->data.refcount--;
if (data->data.refcount > 0)
return;

if (!data->data.is_clone)
free(data->data.buffer);

free(data);
}

2 changes: 1 addition & 1 deletion src/xma/src/xmaapi/xmahw_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ bool hal_configure(XmaHwCfg *hwcfg, XmaSystemCfg *systemcfg, bool hw_configured)
return false;
}
int32_t rc = xma_xclbin_info_get(buffer, &info);
if (rc != 0)
if (rc != XMA_SUCCESS)
{
xma_logmsg("Could not get info for xclbin file %s\n",
xclfullname.c_str());
Expand Down
18 changes: 8 additions & 10 deletions src/xma/src/xmaapi/xmaxclbin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,12 @@ char *xma_xclbin_file_open(const char *xclbin_name)

int xma_xclbin_info_get(char *buffer, XmaXclbinInfo *info)
{
int rc;

rc = get_xclbin_iplayout(buffer, info->ip_layout);
if (rc != 0)
return rc;
return XMA_SUCCESS;
return get_xclbin_iplayout(buffer, info->ip_layout);
}

static int get_xclbin_iplayout(char *buffer, XmaIpLayout *layout)
{
int rc = 0;
//int rc = XMA_SUCCESS;
axlf *xclbin = reinterpret_cast<axlf *>(buffer);

const axlf_section_header *ip_hdr = xclbin::get_axlf_section(xclbin,
Expand All @@ -79,8 +74,11 @@ static int get_xclbin_iplayout(char *buffer, XmaIpLayout *layout)
}
}
else
rc = XMA_ERROR;
{
printf("Could not find IP_LAYOUT in xclbin ip_hdr=%p\n", ip_hdr);
//rc = XMA_ERROR;
return XMA_ERROR;
}

return rc;
return XMA_SUCCESS;
}

0 comments on commit 5352d1a

Please sign in to comment.