Camera3: Set extra usage flags for video stream buffers

For video stream buffers, set READ_RARELY and WRITE_RARELY usage
flags so that gralloc may make them uncached.

Code cleanup

Bug: 10328870
Change-Id: If3bbbbb0976266f69962db7df568c763dad488aa
Signed-off-by: Daniel Jarai <jaraidaniel@gmail.com>
This commit is contained in:
Shuzhen Wang 2013-09-04 22:40:39 -07:00 committed by Artem Borisov
parent 7e6cbb8a35
commit 80470cbf34
3 changed files with 65 additions and 5 deletions

View File

@ -772,7 +772,7 @@ int32_t QCamera3MetadataChannel::registerBuffers(uint32_t /*num_buffers*/,
void QCamera3MetadataChannel::streamCbRoutine(
mm_camera_super_buf_t *super_frame,
QCamera3Stream *stream __unused)
QCamera3Stream * /*stream*/)
{
uint32_t requestNumber = 0;
if (super_frame == NULL || super_frame->num_bufs != 1) {
@ -1970,8 +1970,8 @@ QCamera3ReprocessChannel::QCamera3ReprocessChannel() :
*
* RETURN : none
*==========================================================================*/
int32_t QCamera3ReprocessChannel::registerBuffers(uint32_t num_buffers __unused,
buffer_handle_t **buffers __unused)
int32_t QCamera3ReprocessChannel::registerBuffers(
uint32_t /*num_buffers*/, buffer_handle_t ** /*buffers*/)
{
return 0;
}

View File

@ -137,6 +137,8 @@ camera3_device_ops_t QCamera3HardwareInterface::mCameraOps = {
.process_capture_request = QCamera3HardwareInterface::process_capture_request,
.get_metadata_vendor_tag_ops = QCamera3HardwareInterface::get_metadata_vendor_tag_ops,
.dump = QCamera3HardwareInterface::dump,
.flush = QCamera3HardwareInterface::flush,
.reserved = {0},
};
@ -549,7 +551,15 @@ int QCamera3HardwareInterface::configureStreams(
GRALLOC_USAGE_HW_CAMERA_WRITE;
break;
case CAMERA3_STREAM_OUTPUT:
newStream->usage = GRALLOC_USAGE_HW_CAMERA_WRITE;
/* For video encoding stream, set read/write rarely
* flag so that they may be set to un-cached */
if (newStream->usage & GRALLOC_USAGE_HW_VIDEO_ENCODER)
newStream->usage =
(GRALLOC_USAGE_SW_READ_RARELY |
GRALLOC_USAGE_SW_WRITE_RARELY |
GRALLOC_USAGE_HW_CAMERA_WRITE);
else
newStream->usage = GRALLOC_USAGE_HW_CAMERA_WRITE;
break;
default:
ALOGE("%s: Invalid stream_type %d", __func__, newStream->stream_type);
@ -1049,6 +1059,26 @@ void QCamera3HardwareInterface::dump(int /*fd*/)
return;
}
/*===========================================================================
* FUNCTION : flush
*
* DESCRIPTION:
*
* PARAMETERS :
*
*
* RETURN :
*==========================================================================*/
int QCamera3HardwareInterface::flush()
{
/*Enable lock when we implement this function*/
/*
pthread_mutex_lock(&mMutex);
pthread_mutex_unlock(&mMutex);
*/
return 0;
}
/*===========================================================================
* FUNCTION : captureResultCb
@ -2537,7 +2567,7 @@ int QCamera3HardwareInterface::getCamInfo(int cameraId,
info->orientation = gCamCapability[cameraId]->sensor_mount_angle;
info->device_version = HARDWARE_DEVICE_API_VERSION(3, 0);
info->device_version = CAMERA_DEVICE_API_VERSION_3_0;
info->static_camera_characteristics = gStaticMetadata[cameraId];
return rc;
@ -3600,6 +3630,34 @@ void QCamera3HardwareInterface::dump(
return;
}
/*===========================================================================
* FUNCTION : flush
*
* DESCRIPTION:
*
* PARAMETERS :
*
*
* RETURN :
*==========================================================================*/
int QCamera3HardwareInterface::flush(
const struct camera3_device *device)
{
int rc;
ALOGV("%s: E", __func__);
QCamera3HardwareInterface *hw =
reinterpret_cast<QCamera3HardwareInterface *>(device->priv);
if (!hw) {
ALOGE("%s: NULL camera device", __func__);
return -EINVAL;
}
rc = hw->flush();
ALOGV("%s: X", __func__);
return rc;
}
/*===========================================================================
* FUNCTION : close_camera_device
*

View File

@ -85,6 +85,7 @@ public:
static void get_metadata_vendor_tag_ops(const struct camera3_device *,
vendor_tag_query_ops_t* ops);
static void dump(const struct camera3_device *, int fd);
static int flush(const struct camera3_device *);
static int close_camera_device(struct hw_device_t* device);
public:
QCamera3HardwareInterface(int cameraId);
@ -120,6 +121,7 @@ public:
int processCaptureRequest(camera3_capture_request_t *request);
void getMetadataVendorTagOps(vendor_tag_query_ops_t* ops);
void dump(int fd);
int flush();
int setFrameParameters(int frame_id, const camera_metadata_t *settings,
uint32_t streamTypeMask, cam_trigger_t &aeTrigger);