mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
video: move user define mem_ops into imgdata_ops.
Signed-off-by: yaojingwei <yaojingwei@xiaomi.com>
This commit is contained in:
@@ -1174,9 +1174,9 @@ static void cleanup_streamresources(FAR capture_type_inf_t *type_inf,
|
|||||||
nxmutex_destroy(&type_inf->lock_state);
|
nxmutex_destroy(&type_inf->lock_state);
|
||||||
if (type_inf->bufheap != NULL)
|
if (type_inf->bufheap != NULL)
|
||||||
{
|
{
|
||||||
if (cmng->imgdata->mem_ops && cmng->imgdata->mem_ops->mem_free)
|
if (cmng->imgdata->ops->free)
|
||||||
{
|
{
|
||||||
cmng->imgdata->mem_ops->mem_free(type_inf->bufheap);
|
cmng->imgdata->ops->free(cmng->imgdata, type_inf->bufheap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2120,7 +2120,7 @@ static int capture_reqbufs(FAR struct v4l2_s *v4l2,
|
|||||||
{
|
{
|
||||||
FAR capture_mng_t *cmng = (FAR capture_mng_t *)v4l2;
|
FAR capture_mng_t *cmng = (FAR capture_mng_t *)v4l2;
|
||||||
FAR capture_type_inf_t *type_inf;
|
FAR capture_type_inf_t *type_inf;
|
||||||
const imgdata_mem_ops_t *mem_ops = cmng->imgdata->mem_ops;
|
struct imgdata_s *imgdata = cmng->imgdata;
|
||||||
|
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
@@ -2158,9 +2158,9 @@ static int capture_reqbufs(FAR struct v4l2_s *v4l2,
|
|||||||
{
|
{
|
||||||
if (type_inf->bufheap != NULL)
|
if (type_inf->bufheap != NULL)
|
||||||
{
|
{
|
||||||
if (mem_ops && mem_ops->mem_free)
|
if (imgdata->ops->free)
|
||||||
{
|
{
|
||||||
mem_ops->mem_free(type_inf->bufheap);
|
imgdata->ops->free(imgdata, type_inf->bufheap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2168,9 +2168,10 @@ static int capture_reqbufs(FAR struct v4l2_s *v4l2,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem_ops && mem_ops->mem_malloc)
|
if (imgdata->ops->alloc)
|
||||||
{
|
{
|
||||||
type_inf->bufheap = mem_ops->mem_malloc(32, reqbufs->count *
|
type_inf->bufheap = imgdata->ops->alloc(imgdata, 32,
|
||||||
|
reqbufs->count *
|
||||||
get_bufsize(&type_inf->fmt[CAPTURE_FMT_MAIN]));
|
get_bufsize(&type_inf->fmt[CAPTURE_FMT_MAIN]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -83,14 +83,6 @@ typedef struct imgdata_interval_s
|
|||||||
uint32_t denominator;
|
uint32_t denominator;
|
||||||
} imgdata_interval_t;
|
} imgdata_interval_t;
|
||||||
|
|
||||||
/* Structure for memory operations */
|
|
||||||
|
|
||||||
typedef struct imgdata_mem_ops_s
|
|
||||||
{
|
|
||||||
CODE void *(*mem_malloc)(uint32_t align_size, uint32_t size);
|
|
||||||
CODE void (*mem_free)(void *data);
|
|
||||||
} imgdata_mem_ops_t;
|
|
||||||
|
|
||||||
typedef int (*imgdata_capture_t)(uint8_t result, uint32_t size,
|
typedef int (*imgdata_capture_t)(uint8_t result, uint32_t size,
|
||||||
FAR const struct timeval *ts,
|
FAR const struct timeval *ts,
|
||||||
FAR void *arg);
|
FAR void *arg);
|
||||||
@@ -119,6 +111,14 @@ struct imgdata_ops_s
|
|||||||
FAR imgdata_capture_t callback,
|
FAR imgdata_capture_t callback,
|
||||||
FAR void *arg);
|
FAR void *arg);
|
||||||
CODE int (*stop_capture)(FAR struct imgdata_s *data);
|
CODE int (*stop_capture)(FAR struct imgdata_s *data);
|
||||||
|
|
||||||
|
/* This is a pair of user define frame memory allocation interface.
|
||||||
|
* If both are NULL, just using system memory operations.
|
||||||
|
*/
|
||||||
|
|
||||||
|
CODE void *(*alloc)(FAR struct imgdata_s *data,
|
||||||
|
uint32_t align_size, uint32_t size);
|
||||||
|
CODE void (*free)(FAR struct imgdata_s *data, void *addr);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Image data private data. This structure only defines the initial fields
|
/* Image data private data. This structure only defines the initial fields
|
||||||
@@ -129,7 +129,6 @@ struct imgdata_ops_s
|
|||||||
struct imgdata_s
|
struct imgdata_s
|
||||||
{
|
{
|
||||||
FAR const struct imgdata_ops_s *ops;
|
FAR const struct imgdata_ops_s *ops;
|
||||||
FAR const struct imgdata_mem_ops_s *mem_ops;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user