media: atomisp: get rid of an error abstraction layer

There is an abstraction layer there meant to convert to
the Linux standard error codes. As the driver now use
such errors everywhere. we can get rid of this.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Mauro Carvalho Chehab 2020-05-29 08:42:56 +02:00
parent 41022d35dd
commit a86b4936ba
12 changed files with 83 additions and 158 deletions

View File

@ -16,6 +16,7 @@
* *
* *
*/ */
#include <linux/errno.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
@ -58,7 +59,6 @@
#include "ia_css_types.h" #include "ia_css_types.h"
#include "ia_css_stream.h" #include "ia_css_stream.h"
#include "ia_css_debug.h" #include "ia_css_debug.h"
#include "error_support.h"
#include "bits.h" #include "bits.h"
/* We should never need to run the flash for more than 2 frames. /* We should never need to run the flash for more than 2 frames.

View File

@ -15,8 +15,9 @@
#ifndef __IA_CSS_UTIL_H__ #ifndef __IA_CSS_UTIL_H__
#define __IA_CSS_UTIL_H__ #define __IA_CSS_UTIL_H__
#include <linux/errno.h>
#include <ia_css_err.h> #include <ia_css_err.h>
#include <error_support.h>
#include <type_support.h> #include <type_support.h>
#include <ia_css_frame_public.h> #include <ia_css_frame_public.h>
#include <ia_css_stream_public.h> #include <ia_css_stream_public.h>

View File

@ -20,35 +20,6 @@
/* for ia_css_binary_max_vf_width() */ /* for ia_css_binary_max_vf_width() */
#include "ia_css_binary.h" #include "ia_css_binary.h"
int ia_css_convert_errno(
int in_err)
{
int out_err;
switch (in_err) {
case 0:
out_err = 0;
break;
case EINVAL:
out_err = -EINVAL;
break;
case ENODATA:
out_err = -ENODATA;
break;
case ENOSYS:
case ENOTSUP:
out_err = -EINVAL;
break;
case ENOBUFS:
out_err = -ENOBUFS;
break;
default:
out_err = -EINVAL;
break;
}
return out_err;
}
/* MW: Table look-up ??? */ /* MW: Table look-up ??? */
unsigned int ia_css_util_input_format_bpp( unsigned int ia_css_util_input_format_bpp(
enum atomisp_input_format format, enum atomisp_input_format format,

View File

@ -1,39 +0,0 @@
/*
* Support for Intel Camera Imaging ISP subsystem.
* Copyright (c) 2015, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*/
#ifndef __ERROR_SUPPORT_H_INCLUDED__
#define __ERROR_SUPPORT_H_INCLUDED__
#include <linux/errno.h>
/*
* Put here everything __KERNEL__ specific not covered in
* "errno.h"
*/
#define ENOTSUP 252
#define verifexit(cond, error_tag) \
do { \
if (!(cond)) { \
goto EXIT; \
} \
} while (0)
#define verifjmpexit(cond) \
do { \
if (!(cond)) { \
goto EXIT; \
} \
} while (0)
#endif /* __ERROR_SUPPORT_H_INCLUDED__ */

View File

@ -28,7 +28,7 @@
* @param[in] src_buf. The source buffer * @param[in] src_buf. The source buffer
* @param[in] src_size. The size of the source buffer in bytes * @param[in] src_size. The size of the source buffer in bytes
* @return 0 on success, error code on failure * @return 0 on success, error code on failure
* @return EINVAL on Invalid arguments * @return -EINVAL on Invalid arguments
* @return ERANGE on Destination size too small * @return ERANGE on Destination size too small
*/ */
static inline int memcpy_s( static inline int memcpy_s(
@ -39,7 +39,7 @@ static inline int memcpy_s(
{ {
if ((!src_buf) || (!dest_buf)) { if ((!src_buf) || (!dest_buf)) {
/* Invalid arguments*/ /* Invalid arguments*/
return EINVAL; return -EINVAL;
} }
if ((dest_size < src_size) || (src_size == 0)) { if ((dest_size < src_size) || (src_size == 0)) {
@ -84,7 +84,7 @@ static size_t strnlen_s(
* @param[in] src_str. The source buffer * @param[in] src_str. The source buffer
* @param[in] src_size. The size of the source buffer in bytes * @param[in] src_size. The size of the source buffer in bytes
* @return Returns 0 on success * @return Returns 0 on success
* @return Returns EINVAL on invalid arguments * @return Returns -EINVAL on invalid arguments
* @return Returns ERANGE on destination size too small * @return Returns ERANGE on destination size too small
*/ */
static inline int strncpy_s( static inline int strncpy_s(
@ -97,13 +97,13 @@ static inline int strncpy_s(
if (!dest_str) { if (!dest_str) {
/* Invalid arguments*/ /* Invalid arguments*/
return EINVAL; return -EINVAL;
} }
if ((!src_str) || (dest_size == 0)) { if ((!src_str) || (dest_size == 0)) {
/* Invalid arguments*/ /* Invalid arguments*/
dest_str[0] = '\0'; dest_str[0] = '\0';
return EINVAL; return -EINVAL;
} }
len = strnlen_s(src_str, src_size); len = strnlen_s(src_str, src_size);
@ -126,7 +126,7 @@ static inline int strncpy_s(
* @param[in] dest_size. The size of the destination buffer in bytes * @param[in] dest_size. The size of the destination buffer in bytes
* @param[in] src_str. The source buffer * @param[in] src_str. The source buffer
* @return Returns 0 on success * @return Returns 0 on success
* @return Returns EINVAL on invalid arguments * @return Returns -EINVAL on invalid arguments
* @return Returns ERANGE on destination size too small * @return Returns ERANGE on destination size too small
*/ */
static inline int strcpy_s( static inline int strcpy_s(
@ -138,13 +138,13 @@ static inline int strcpy_s(
if (!dest_str) { if (!dest_str) {
/* Invalid arguments*/ /* Invalid arguments*/
return EINVAL; return -EINVAL;
} }
if ((!src_str) || (dest_size == 0)) { if ((!src_str) || (dest_size == 0)) {
/* Invalid arguments*/ /* Invalid arguments*/
dest_str[0] = '\0'; dest_str[0] = '\0';
return EINVAL; return -EINVAL;
} }
len = strnlen_s(src_str, dest_size); len = strnlen_s(src_str, dest_size);

View File

@ -22,7 +22,6 @@
#include "ia_css_debug.h" /* ia_css_debug_dtrace*/ #include "ia_css_debug.h" /* ia_css_debug_dtrace*/
#include "sh_css_internal.h" /* sh_css_queue_type */ #include "sh_css_internal.h" /* sh_css_queue_type */
#include "sp_local.h" /* sp_address_of */ #include "sp_local.h" /* sp_address_of */
#include "ia_css_util.h" /* ia_css_convert_errno()*/
#include "sh_css_firmware.h" /* sh_css_sp_fw*/ #include "sh_css_firmware.h" /* sh_css_sp_fw*/
#define BUFQ_DUMP_FILE_NAME_PREFIX_SIZE 256 #define BUFQ_DUMP_FILE_NAME_PREFIX_SIZE 256
@ -334,7 +333,6 @@ int ia_css_bufq_enqueue_buffer(
int queue_id, int queue_id,
uint32_t item) uint32_t item)
{ {
int return_err = 0;
ia_css_queue_t *q; ia_css_queue_t *q;
int error; int error;
@ -349,22 +347,20 @@ int ia_css_bufq_enqueue_buffer(
thread_index); thread_index);
if (q) { if (q) {
error = ia_css_queue_enqueue(q, item); error = ia_css_queue_enqueue(q, item);
return_err = ia_css_convert_errno(error);
} else { } else {
IA_CSS_ERROR("queue is not initialized"); IA_CSS_ERROR("queue is not initialized");
return_err = -EBUSY; error = -EBUSY;
} }
IA_CSS_LEAVE_ERR_PRIVATE(return_err); IA_CSS_LEAVE_ERR_PRIVATE(error);
return return_err; return error;
} }
int ia_css_bufq_dequeue_buffer( int ia_css_bufq_dequeue_buffer(
int queue_id, int queue_id,
uint32_t *item) uint32_t *item)
{ {
int return_err; int error;
int error = 0;
ia_css_queue_t *q; ia_css_queue_t *q;
IA_CSS_ENTER_PRIVATE("queue_id=%d", queue_id); IA_CSS_ENTER_PRIVATE("queue_id=%d", queue_id);
@ -379,14 +375,13 @@ int ia_css_bufq_dequeue_buffer(
-1); -1);
if (q) { if (q) {
error = ia_css_queue_dequeue(q, item); error = ia_css_queue_dequeue(q, item);
return_err = ia_css_convert_errno(error);
} else { } else {
IA_CSS_ERROR("queue is not initialized"); IA_CSS_ERROR("queue is not initialized");
return_err = -EBUSY; error = -EBUSY;
} }
IA_CSS_LEAVE_ERR_PRIVATE(return_err); IA_CSS_LEAVE_ERR_PRIVATE(error);
return return_err; return error;
} }
int ia_css_bufq_enqueue_psys_event( int ia_css_bufq_enqueue_psys_event(
@ -395,7 +390,7 @@ int ia_css_bufq_enqueue_psys_event(
u8 evt_payload_1, u8 evt_payload_1,
uint8_t evt_payload_2) uint8_t evt_payload_2)
{ {
int return_err;
int error = 0; int error = 0;
ia_css_queue_t *q; ia_css_queue_t *q;
@ -409,9 +404,8 @@ int ia_css_bufq_enqueue_psys_event(
error = ia_css_eventq_send(q, error = ia_css_eventq_send(q,
evt_id, evt_payload_0, evt_payload_1, evt_payload_2); evt_id, evt_payload_0, evt_payload_1, evt_payload_2);
return_err = ia_css_convert_errno(error); IA_CSS_LEAVE_ERR_PRIVATE(error);
IA_CSS_LEAVE_ERR_PRIVATE(return_err); return error;
return return_err;
} }
int ia_css_bufq_dequeue_psys_event( int ia_css_bufq_dequeue_psys_event(
@ -433,7 +427,7 @@ int ia_css_bufq_dequeue_psys_event(
} }
error = ia_css_eventq_recv(q, item); error = ia_css_eventq_recv(q, item);
return ia_css_convert_errno(error); return error;
} }
int ia_css_bufq_dequeue_isys_event( int ia_css_bufq_dequeue_isys_event(
@ -455,7 +449,7 @@ int ia_css_bufq_dequeue_isys_event(
return -EBUSY; return -EBUSY;
} }
error = ia_css_eventq_recv(q, item); error = ia_css_eventq_recv(q, item);
return ia_css_convert_errno(error); return error;
#else #else
(void)item; (void)item;
return -EBUSY; return -EBUSY;
@ -465,7 +459,6 @@ int ia_css_bufq_dequeue_isys_event(
int ia_css_bufq_enqueue_isys_event(uint8_t evt_id) int ia_css_bufq_enqueue_isys_event(uint8_t evt_id)
{ {
#if !defined(HAS_NO_INPUT_SYSTEM) #if !defined(HAS_NO_INPUT_SYSTEM)
int return_err;
int error = 0; int error = 0;
ia_css_queue_t *q; ia_css_queue_t *q;
@ -477,9 +470,9 @@ int ia_css_bufq_enqueue_isys_event(uint8_t evt_id)
} }
error = ia_css_eventq_send(q, evt_id, 0, 0, 0); error = ia_css_eventq_send(q, evt_id, 0, 0, 0);
return_err = ia_css_convert_errno(error);
IA_CSS_LEAVE_ERR_PRIVATE(return_err); IA_CSS_LEAVE_ERR_PRIVATE(error);
return return_err; return error;
#else #else
(void)evt_id; (void)evt_id;
return -EBUSY; return -EBUSY;
@ -490,8 +483,7 @@ int ia_css_bufq_enqueue_tag_cmd(
uint32_t item) uint32_t item)
{ {
#if !defined(HAS_NO_INPUT_SYSTEM) #if !defined(HAS_NO_INPUT_SYSTEM)
int return_err; int error;
int error = 0;
ia_css_queue_t *q; ia_css_queue_t *q;
IA_CSS_ENTER_PRIVATE("item=%d", item); IA_CSS_ENTER_PRIVATE("item=%d", item);
@ -502,9 +494,8 @@ int ia_css_bufq_enqueue_tag_cmd(
} }
error = ia_css_queue_enqueue(q, item); error = ia_css_queue_enqueue(q, item);
return_err = ia_css_convert_errno(error); IA_CSS_LEAVE_ERR_PRIVATE(error);
IA_CSS_LEAVE_ERR_PRIVATE(return_err); return error;
return return_err;
#else #else
(void)item; (void)item;
return -EBUSY; return -EBUSY;

View File

@ -23,8 +23,8 @@
* @param[in] eventq_handle eventq_handle. * @param[in] eventq_handle eventq_handle.
* @param[in] payload The event payload. * @param[in] payload The event payload.
* @return 0 - Successfully dequeue. * @return 0 - Successfully dequeue.
* @return EINVAL - Invalid argument. * @return -EINVAL - Invalid argument.
* @return ENODATA - Queue is empty. * @return -ENODATA - Queue is empty.
*/ */
int ia_css_eventq_recv( int ia_css_eventq_recv(
ia_css_queue_t *eventq_handle, ia_css_queue_t *eventq_handle,
@ -41,8 +41,8 @@ int ia_css_eventq_recv(
* @param[in] evt_payload_1 The event payload. * @param[in] evt_payload_1 The event payload.
* @param[in] evt_payload_2 The event payload. * @param[in] evt_payload_2 The event payload.
* @return 0 - Successfully enqueue. * @return 0 - Successfully enqueue.
* @return EINVAL - Invalid argument. * @return -EINVAL - Invalid argument.
* @return ENOBUFS - Queue is full. * @return -ENOBUFS - Queue is full.
*/ */
int ia_css_eventq_send( int ia_css_eventq_send(
ia_css_queue_t *eventq_handle, ia_css_queue_t *eventq_handle,

View File

@ -50,7 +50,7 @@ int ia_css_eventq_send(
{ {
u8 tmp[4]; u8 tmp[4];
u32 sw_event; u32 sw_event;
int error = ENOSYS; int error = -ENOSYS;
/* /*
* Encode the queue type, the thread ID and * Encode the queue type, the thread ID and
@ -65,7 +65,7 @@ int ia_css_eventq_send(
/* queue the software event (busy-waiting) */ /* queue the software event (busy-waiting) */
for ( ; ; ) { for ( ; ; ) {
error = ia_css_queue_enqueue(eventq_handle, sw_event); error = ia_css_queue_enqueue(eventq_handle, sw_event);
if (error != ENOBUFS) { if (error != -ENOBUFS) {
/* We were able to successfully send the event /* We were able to successfully send the event
or had a real failure. return the status*/ or had a real failure. return the status*/
break; break;

View File

@ -40,7 +40,7 @@ typedef struct ia_css_queue ia_css_queue_t;
* @param[out] qhandle. Handle to queue instance for use with API * @param[out] qhandle. Handle to queue instance for use with API
* @param[in] desc. Descriptor with queue properties filled-in * @param[in] desc. Descriptor with queue properties filled-in
* @return 0 - Successful init of local queue instance. * @return 0 - Successful init of local queue instance.
* @return EINVAL - Invalid argument. * @return -EINVAL - Invalid argument.
* *
*/ */
int ia_css_queue_local_init( int ia_css_queue_local_init(
@ -52,7 +52,7 @@ int ia_css_queue_local_init(
* @param[out] qhandle. Handle to queue instance for use with API * @param[out] qhandle. Handle to queue instance for use with API
* @param[in] desc. Descriptor with queue properties filled-in * @param[in] desc. Descriptor with queue properties filled-in
* @return 0 - Successful init of remote queue instance. * @return 0 - Successful init of remote queue instance.
* @return EINVAL - Invalid argument. * @return -EINVAL - Invalid argument.
*/ */
int ia_css_queue_remote_init( int ia_css_queue_remote_init(
ia_css_queue_t *qhandle, ia_css_queue_t *qhandle,
@ -72,8 +72,8 @@ int ia_css_queue_uninit(
* @param[in] qhandle. Handle to queue instance * @param[in] qhandle. Handle to queue instance
* @param[in] item. Object to be enqueued. * @param[in] item. Object to be enqueued.
* @return 0 - Successful enqueue. * @return 0 - Successful enqueue.
* @return EINVAL - Invalid argument. * @return -EINVAL - Invalid argument.
* @return ENOBUFS - Queue is full. * @return -ENOBUFS - Queue is full.
* *
*/ */
int ia_css_queue_enqueue( int ia_css_queue_enqueue(
@ -86,8 +86,8 @@ int ia_css_queue_enqueue(
* @param[out] item. Object to be dequeued into this item. * @param[out] item. Object to be dequeued into this item.
* @return 0 - Successful dequeue. * @return 0 - Successful dequeue.
* @return EINVAL - Invalid argument. * @return -EINVAL - Invalid argument.
* @return ENODATA - Queue is empty. * @return -ENODATA - Queue is empty.
* *
*/ */
int ia_css_queue_dequeue( int ia_css_queue_dequeue(
@ -99,8 +99,8 @@ int ia_css_queue_dequeue(
* @param[in] qhandle. Handle to queue instance * @param[in] qhandle. Handle to queue instance
* @param[in] is_empty True if empty, False if not. * @param[in] is_empty True if empty, False if not.
* @return 0 - Successful access state. * @return 0 - Successful access state.
* @return EINVAL - Invalid argument. * @return -EINVAL - Invalid argument.
* @return ENOSYS - Function not implemented. * @return -ENOSYS - Function not implemented.
* *
*/ */
int ia_css_queue_is_empty( int ia_css_queue_is_empty(
@ -112,8 +112,8 @@ int ia_css_queue_is_empty(
* @param[in] qhandle. Handle to queue instance * @param[in] qhandle. Handle to queue instance
* @param[in] is_full True if Full, False if not. * @param[in] is_full True if Full, False if not.
* @return 0 - Successfully access state. * @return 0 - Successfully access state.
* @return EINVAL - Invalid argument. * @return -EINVAL - Invalid argument.
* @return ENOSYS - Function not implemented. * @return -ENOSYS - Function not implemented.
* *
*/ */
int ia_css_queue_is_full( int ia_css_queue_is_full(
@ -125,7 +125,7 @@ int ia_css_queue_is_full(
* @param[in] qhandle. Handle to queue instance * @param[in] qhandle. Handle to queue instance
* @param[in] size Number of available elements in the queue * @param[in] size Number of available elements in the queue
* @return 0 - Successfully access state. * @return 0 - Successfully access state.
* @return EINVAL - Invalid argument. * @return -EINVAL - Invalid argument.
* *
*/ */
int ia_css_queue_get_used_space( int ia_css_queue_get_used_space(
@ -137,7 +137,7 @@ int ia_css_queue_get_used_space(
* @param[in] qhandle. Handle to queue instance * @param[in] qhandle. Handle to queue instance
* @param[in] size Number of free elements in the queue * @param[in] size Number of free elements in the queue
* @return 0 - Successfully access state. * @return 0 - Successfully access state.
* @return EINVAL - Invalid argument. * @return -EINVAL - Invalid argument.
* *
*/ */
int ia_css_queue_get_free_space( int ia_css_queue_get_free_space(
@ -151,7 +151,7 @@ int ia_css_queue_get_free_space(
* starting from head of queue * starting from head of queue
* @param[in] element Value of element returned * @param[in] element Value of element returned
* @return 0 - Successfully access state. * @return 0 - Successfully access state.
* @return EINVAL - Invalid argument. * @return -EINVAL - Invalid argument.
* *
*/ */
int ia_css_queue_peek( int ia_css_queue_peek(
@ -164,8 +164,8 @@ int ia_css_queue_peek(
* @param[in] qhandle. Handle to queue instance * @param[in] qhandle. Handle to queue instance
* @param[out] size Size value to be returned here. * @param[out] size Size value to be returned here.
* @return 0 - Successful get size. * @return 0 - Successful get size.
* @return EINVAL - Invalid argument. * @return -EINVAL - Invalid argument.
* @return ENOSYS - Function not implemented. * @return -ENOSYS - Function not implemented.
* *
*/ */
int ia_css_queue_get_size( int ia_css_queue_get_size(

View File

@ -28,7 +28,7 @@ int ia_css_queue_local_init(
if (NULL == qhandle || NULL == desc if (NULL == qhandle || NULL == desc
|| NULL == desc->cb_elems || NULL == desc->cb_desc) { || NULL == desc->cb_elems || NULL == desc->cb_desc) {
/* Invalid parameters, return error*/ /* Invalid parameters, return error*/
return EINVAL; return -EINVAL;
} }
/* Mark the queue as Local */ /* Mark the queue as Local */
@ -48,7 +48,7 @@ int ia_css_queue_remote_init(
{ {
if (NULL == qhandle || NULL == desc) { if (NULL == qhandle || NULL == desc) {
/* Invalid parameters, return error*/ /* Invalid parameters, return error*/
return EINVAL; return -EINVAL;
} }
/* Mark the queue as remote*/ /* Mark the queue as remote*/
@ -72,7 +72,7 @@ int ia_css_queue_uninit(
ia_css_queue_t *qhandle) ia_css_queue_t *qhandle)
{ {
if (!qhandle) if (!qhandle)
return EINVAL; return -EINVAL;
/* Load the required queue object */ /* Load the required queue object */
if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) { if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) {
@ -90,7 +90,7 @@ int ia_css_queue_enqueue(
int error = 0; int error = 0;
if (!qhandle) if (!qhandle)
return EINVAL; return -EINVAL;
/* 1. Load the required queue object */ /* 1. Load the required queue object */
if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) { if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) {
@ -99,7 +99,7 @@ int ia_css_queue_enqueue(
*/ */
if (ia_css_circbuf_is_full(&qhandle->desc.cb_local)) { if (ia_css_circbuf_is_full(&qhandle->desc.cb_local)) {
/* Cannot push the element. Return*/ /* Cannot push the element. Return*/
return ENOBUFS; return -ENOBUFS;
} }
/* Push the element*/ /* Push the element*/
@ -117,7 +117,7 @@ int ia_css_queue_enqueue(
/* b. Operate on the queue */ /* b. Operate on the queue */
if (ia_css_circbuf_desc_is_full(&cb_desc)) if (ia_css_circbuf_desc_is_full(&cb_desc))
return ENOBUFS; return -ENOBUFS;
cb_elem.val = item; cb_elem.val = item;
@ -149,7 +149,7 @@ int ia_css_queue_dequeue(
int error = 0; int error = 0;
if (!qhandle || NULL == item) if (!qhandle || NULL == item)
return EINVAL; return -EINVAL;
/* 1. Load the required queue object */ /* 1. Load the required queue object */
if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) { if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) {
@ -158,7 +158,7 @@ int ia_css_queue_dequeue(
*/ */
if (ia_css_circbuf_is_empty(&qhandle->desc.cb_local)) { if (ia_css_circbuf_is_empty(&qhandle->desc.cb_local)) {
/* Nothing to pop. Return empty queue*/ /* Nothing to pop. Return empty queue*/
return ENODATA; return -ENODATA;
} }
*item = ia_css_circbuf_pop(&qhandle->desc.cb_local); *item = ia_css_circbuf_pop(&qhandle->desc.cb_local);
@ -176,7 +176,7 @@ int ia_css_queue_dequeue(
/* b. Operate on the queue */ /* b. Operate on the queue */
if (ia_css_circbuf_desc_is_empty(&cb_desc)) if (ia_css_circbuf_desc_is_empty(&cb_desc))
return ENODATA; return -ENODATA;
error = ia_css_queue_item_load(qhandle, cb_desc.start, &cb_elem); error = ia_css_queue_item_load(qhandle, cb_desc.start, &cb_elem);
if (error != 0) if (error != 0)
@ -206,7 +206,7 @@ int ia_css_queue_is_full(
int error = 0; int error = 0;
if ((!qhandle) || (!is_full)) if ((!qhandle) || (!is_full))
return EINVAL; return -EINVAL;
/* 1. Load the required queue object */ /* 1. Load the required queue object */
if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) { if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) {
@ -230,7 +230,7 @@ int ia_css_queue_is_full(
return 0; return 0;
} }
return EINVAL; return -EINVAL;
} }
int ia_css_queue_get_free_space( int ia_css_queue_get_free_space(
@ -240,7 +240,7 @@ int ia_css_queue_get_free_space(
int error = 0; int error = 0;
if ((!qhandle) || (!size)) if ((!qhandle) || (!size))
return EINVAL; return -EINVAL;
/* 1. Load the required queue object */ /* 1. Load the required queue object */
if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) { if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) {
@ -264,7 +264,7 @@ int ia_css_queue_get_free_space(
return 0; return 0;
} }
return EINVAL; return -EINVAL;
} }
int ia_css_queue_get_used_space( int ia_css_queue_get_used_space(
@ -274,7 +274,7 @@ int ia_css_queue_get_used_space(
int error = 0; int error = 0;
if ((!qhandle) || (!size)) if ((!qhandle) || (!size))
return EINVAL; return -EINVAL;
/* 1. Load the required queue object */ /* 1. Load the required queue object */
if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) { if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) {
@ -298,7 +298,7 @@ int ia_css_queue_get_used_space(
return 0; return 0;
} }
return EINVAL; return -EINVAL;
} }
int ia_css_queue_peek( int ia_css_queue_peek(
@ -310,7 +310,7 @@ int ia_css_queue_peek(
int error = 0; int error = 0;
if ((!qhandle) || (!element)) if ((!qhandle) || (!element))
return EINVAL; return -EINVAL;
/* 1. Load the required queue object */ /* 1. Load the required queue object */
if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) { if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) {
@ -320,7 +320,7 @@ int ia_css_queue_peek(
/* Check if offset is valid */ /* Check if offset is valid */
num_elems = ia_css_circbuf_get_num_elems(&qhandle->desc.cb_local); num_elems = ia_css_circbuf_get_num_elems(&qhandle->desc.cb_local);
if (offset > num_elems) if (offset > num_elems)
return EINVAL; return -EINVAL;
*element = ia_css_circbuf_peek_from_start(&qhandle->desc.cb_local, (int)offset); *element = ia_css_circbuf_peek_from_start(&qhandle->desc.cb_local, (int)offset);
return 0; return 0;
@ -339,7 +339,7 @@ int ia_css_queue_peek(
/* Check if offset is valid */ /* Check if offset is valid */
num_elems = ia_css_circbuf_desc_get_num_elems(&cb_desc); num_elems = ia_css_circbuf_desc_get_num_elems(&cb_desc);
if (offset > num_elems) if (offset > num_elems)
return EINVAL; return -EINVAL;
offset = OP_std_modadd(cb_desc.start, offset, cb_desc.size); offset = OP_std_modadd(cb_desc.start, offset, cb_desc.size);
error = ia_css_queue_item_load(qhandle, (uint8_t)offset, &cb_elem); error = ia_css_queue_item_load(qhandle, (uint8_t)offset, &cb_elem);
@ -350,7 +350,7 @@ int ia_css_queue_peek(
return 0; return 0;
} }
return EINVAL; return -EINVAL;
} }
int ia_css_queue_is_empty( int ia_css_queue_is_empty(
@ -360,7 +360,7 @@ int ia_css_queue_is_empty(
int error = 0; int error = 0;
if ((!qhandle) || (!is_empty)) if ((!qhandle) || (!is_empty))
return EINVAL; return -EINVAL;
/* 1. Load the required queue object */ /* 1. Load the required queue object */
if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) { if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) {
@ -384,7 +384,7 @@ int ia_css_queue_is_empty(
return 0; return 0;
} }
return EINVAL; return -EINVAL;
} }
int ia_css_queue_get_size( int ia_css_queue_get_size(
@ -394,7 +394,7 @@ int ia_css_queue_get_size(
int error = 0; int error = 0;
if ((!qhandle) || (!size)) if ((!qhandle) || (!size))
return EINVAL; return -EINVAL;
/* 1. Load the required queue object */ /* 1. Load the required queue object */
if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) { if (qhandle->type == IA_CSS_QUEUE_TYPE_LOCAL) {

View File

@ -26,7 +26,7 @@ int ia_css_queue_load(
uint32_t ignore_desc_flags) uint32_t ignore_desc_flags)
{ {
if (!rdesc || !cb_desc) if (!rdesc || !cb_desc)
return EINVAL; return -EINVAL;
if (rdesc->location == IA_CSS_QUEUE_LOC_SP) { if (rdesc->location == IA_CSS_QUEUE_LOC_SP) {
assert(ignore_desc_flags <= QUEUE_IGNORE_DESC_FLAGS_MAX); assert(ignore_desc_flags <= QUEUE_IGNORE_DESC_FLAGS_MAX);
@ -69,7 +69,7 @@ int ia_css_queue_load(
sizeof(ia_css_circbuf_desc_t)); sizeof(ia_css_circbuf_desc_t));
} else if (rdesc->location == IA_CSS_QUEUE_LOC_ISP) { } else if (rdesc->location == IA_CSS_QUEUE_LOC_ISP) {
/* Not supported yet */ /* Not supported yet */
return ENOTSUP; return -ENOTSUPP;
} }
return 0; return 0;
@ -81,7 +81,7 @@ int ia_css_queue_store(
uint32_t ignore_desc_flags) uint32_t ignore_desc_flags)
{ {
if (!rdesc || !cb_desc) if (!rdesc || !cb_desc)
return EINVAL; return -EINVAL;
if (rdesc->location == IA_CSS_QUEUE_LOC_SP) { if (rdesc->location == IA_CSS_QUEUE_LOC_SP) {
assert(ignore_desc_flags <= QUEUE_IGNORE_DESC_FLAGS_MAX); assert(ignore_desc_flags <= QUEUE_IGNORE_DESC_FLAGS_MAX);
@ -116,7 +116,7 @@ int ia_css_queue_store(
sizeof(ia_css_circbuf_desc_t)); sizeof(ia_css_circbuf_desc_t));
} else if (rdesc->location == IA_CSS_QUEUE_LOC_ISP) { } else if (rdesc->location == IA_CSS_QUEUE_LOC_ISP) {
/* Not supported yet */ /* Not supported yet */
return ENOTSUP; return -ENOTSUPP;
} }
return 0; return 0;
@ -128,7 +128,7 @@ int ia_css_queue_item_load(
ia_css_circbuf_elem_t *item) ia_css_circbuf_elem_t *item)
{ {
if (!rdesc || !item) if (!rdesc || !item)
return EINVAL; return -EINVAL;
if (rdesc->location == IA_CSS_QUEUE_LOC_SP) { if (rdesc->location == IA_CSS_QUEUE_LOC_SP) {
sp_dmem_load(rdesc->proc_id, sp_dmem_load(rdesc->proc_id,
@ -143,7 +143,7 @@ int ia_css_queue_item_load(
sizeof(ia_css_circbuf_elem_t)); sizeof(ia_css_circbuf_elem_t));
} else if (rdesc->location == IA_CSS_QUEUE_LOC_ISP) { } else if (rdesc->location == IA_CSS_QUEUE_LOC_ISP) {
/* Not supported yet */ /* Not supported yet */
return ENOTSUP; return -ENOTSUPP;
} }
return 0; return 0;
@ -155,7 +155,7 @@ int ia_css_queue_item_store(
ia_css_circbuf_elem_t *item) ia_css_circbuf_elem_t *item)
{ {
if (!rdesc || !item) if (!rdesc || !item)
return EINVAL; return -EINVAL;
if (rdesc->location == IA_CSS_QUEUE_LOC_SP) { if (rdesc->location == IA_CSS_QUEUE_LOC_SP) {
sp_dmem_store(rdesc->proc_id, sp_dmem_store(rdesc->proc_id,
@ -170,7 +170,7 @@ int ia_css_queue_item_store(
sizeof(ia_css_circbuf_elem_t)); sizeof(ia_css_circbuf_elem_t));
} else if (rdesc->location == IA_CSS_QUEUE_LOC_ISP) { } else if (rdesc->location == IA_CSS_QUEUE_LOC_ISP) {
/* Not supported yet */ /* Not supported yet */
return ENOTSUP; return -ENOTSUPP;
} }
return 0; return 0;

View File

@ -15,10 +15,11 @@
#ifndef __QUEUE_ACCESS_H #ifndef __QUEUE_ACCESS_H
#define __QUEUE_ACCESS_H #define __QUEUE_ACCESS_H
#include <linux/errno.h>
#include <type_support.h> #include <type_support.h>
#include <ia_css_queue_comm.h> #include <ia_css_queue_comm.h>
#include <ia_css_circbuf.h> #include <ia_css_circbuf.h>
#include <error_support.h>
#define QUEUE_IGNORE_START_FLAG 0x0001 #define QUEUE_IGNORE_START_FLAG 0x0001
#define QUEUE_IGNORE_END_FLAG 0x0002 #define QUEUE_IGNORE_END_FLAG 0x0002