summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/camera/libcameraservice/CameraFlashlight.cpp2
-rw-r--r--services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp4
-rw-r--r--services/camera/libcameraservice/api1/client2/JpegProcessor.cpp2
-rw-r--r--services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp6
-rw-r--r--services/camera/libcameraservice/api1/client2/ZslProcessor.cpp4
-rw-r--r--services/camera/libcameraservice/api2/CameraDeviceClient.cpp9
-rw-r--r--services/camera/libcameraservice/api2/CameraDeviceClient.h4
-rw-r--r--services/camera/libcameraservice/api_pro/ProCamera2Client.cpp3
-rw-r--r--services/camera/libcameraservice/common/CameraDeviceBase.h4
-rw-r--r--services/camera/libcameraservice/device2/Camera2Device.cpp2
-rw-r--r--services/camera/libcameraservice/device2/Camera2Device.h2
-rw-r--r--services/camera/libcameraservice/device3/Camera3Device.cpp10
-rw-r--r--services/camera/libcameraservice/device3/Camera3Device.h2
-rw-r--r--services/camera/libcameraservice/device3/Camera3DummyStream.cpp2
-rw-r--r--services/camera/libcameraservice/device3/Camera3DummyStream.h1
-rw-r--r--services/camera/libcameraservice/device3/Camera3IOStreamBase.cpp4
-rw-r--r--services/camera/libcameraservice/device3/Camera3IOStreamBase.h2
-rw-r--r--services/camera/libcameraservice/device3/Camera3InputStream.cpp4
-rw-r--r--services/camera/libcameraservice/device3/Camera3OutputStream.cpp13
-rw-r--r--services/camera/libcameraservice/device3/Camera3OutputStream.h6
-rw-r--r--services/camera/libcameraservice/device3/Camera3Stream.cpp3
-rw-r--r--services/camera/libcameraservice/device3/Camera3Stream.h2
-rw-r--r--services/camera/libcameraservice/device3/Camera3ZslStream.cpp2
-rw-r--r--services/radio/Android.mk1
-rw-r--r--services/radio/RadioService.cpp94
-rw-r--r--services/radio/RadioService.h48
26 files changed, 151 insertions, 85 deletions
diff --git a/services/camera/libcameraservice/CameraFlashlight.cpp b/services/camera/libcameraservice/CameraFlashlight.cpp
index 0def668..6fda9b2 100644
--- a/services/camera/libcameraservice/CameraFlashlight.cpp
+++ b/services/camera/libcameraservice/CameraFlashlight.cpp
@@ -403,7 +403,7 @@ status_t CameraDeviceClientFlashControl::initializeSurface(
return NO_MEMORY;
}
res = device->createStream(mAnw, width, height, format,
- HAL_DATASPACE_UNKNOWN, &mStreamId);
+ HAL_DATASPACE_UNKNOWN, CAMERA3_STREAM_ROTATION_0, &mStreamId);
if (res) {
return res;
}
diff --git a/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp b/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp
index fd4e714..5c8f750 100644
--- a/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/CallbackProcessor.cpp
@@ -154,8 +154,8 @@ status_t CallbackProcessor::updateStream(const Parameters &params) {
params.previewWidth, params.previewHeight,
callbackFormat, params.previewFormat);
res = device->createStream(mCallbackWindow,
- params.previewWidth, params.previewHeight,
- callbackFormat, HAL_DATASPACE_JFIF, &mCallbackStreamId);
+ params.previewWidth, params.previewHeight, callbackFormat,
+ HAL_DATASPACE_JFIF, CAMERA3_STREAM_ROTATION_0, &mCallbackStreamId);
if (res != OK) {
ALOGE("%s: Camera %d: Can't create output stream for callbacks: "
"%s (%d)", __FUNCTION__, mId,
diff --git a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
index 5b387f9..34798bf 100644
--- a/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/JpegProcessor.cpp
@@ -146,7 +146,7 @@ status_t JpegProcessor::updateStream(const Parameters &params) {
res = device->createStream(mCaptureWindow,
params.pictureWidth, params.pictureHeight,
HAL_PIXEL_FORMAT_BLOB, HAL_DATASPACE_JFIF,
- &mCaptureStreamId);
+ CAMERA3_STREAM_ROTATION_0, &mCaptureStreamId);
if (res != OK) {
ALOGE("%s: Camera %d: Can't create output stream for capture: "
"%s (%d)", __FUNCTION__, mId,
diff --git a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp
index a5a2fec..b6071f6 100644
--- a/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/StreamingProcessor.cpp
@@ -183,7 +183,7 @@ status_t StreamingProcessor::updatePreviewStream(const Parameters &params) {
res = device->createStream(mPreviewWindow,
params.previewWidth, params.previewHeight,
CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, HAL_DATASPACE_UNKNOWN,
- &mPreviewStreamId);
+ CAMERA3_STREAM_ROTATION_0, &mPreviewStreamId);
if (res != OK) {
ALOGE("%s: Camera %d: Unable to create preview stream: %s (%d)",
__FUNCTION__, mId, strerror(-res), res);
@@ -426,8 +426,8 @@ status_t StreamingProcessor::updateRecordingStream(const Parameters &params) {
// TODO: Wire this in from encoder side
res = device->createStream(mRecordingWindow,
params.videoWidth, params.videoHeight,
- CAMERA2_HAL_PIXEL_FORMAT_OPAQUE,
- HAL_DATASPACE_BT709, &mRecordingStreamId);
+ CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, HAL_DATASPACE_BT709,
+ CAMERA3_STREAM_ROTATION_0, &mRecordingStreamId);
if (res != OK) {
ALOGE("%s: Camera %d: Can't create output stream for recording: "
"%s (%d)", __FUNCTION__, mId,
diff --git a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
index 68aca2d..a03f9c7 100644
--- a/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
+++ b/services/camera/libcameraservice/api1/client2/ZslProcessor.cpp
@@ -185,8 +185,8 @@ status_t ZslProcessor::updateStream(const Parameters &params) {
(int)CAMERA2_HAL_PIXEL_FORMAT_ZSL :
(int)HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
res = device->createStream(mZslWindow,
- params.fastInfo.arrayWidth, params.fastInfo.arrayHeight,
- streamType, HAL_DATASPACE_UNKNOWN, &mZslStreamId);
+ params.fastInfo.arrayWidth, params.fastInfo.arrayHeight, streamType,
+ HAL_DATASPACE_UNKNOWN, CAMERA3_STREAM_ROTATION_0, &mZslStreamId);
if (res != OK) {
ALOGE("%s: Camera %d: Can't create output stream for ZSL: "
"%s (%d)", __FUNCTION__, mId,
diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
index ad10bda..0e2311c 100644
--- a/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.cpp
@@ -314,8 +314,7 @@ status_t CameraDeviceClient::deleteStream(int streamId) {
return res;
}
-status_t CameraDeviceClient::createStream(
- const sp<IGraphicBufferProducer>& bufferProducer)
+status_t CameraDeviceClient::createStream(const OutputConfiguration &outputConfiguration)
{
ATRACE_CALL();
@@ -324,6 +323,8 @@ status_t CameraDeviceClient::createStream(
Mutex::Autolock icl(mBinderSerializationLock);
+
+ sp<IGraphicBufferProducer> bufferProducer = outputConfiguration.getGraphicBufferProducer();
if (bufferProducer == NULL) {
ALOGE("%s: bufferProducer must not be null", __FUNCTION__);
return BAD_VALUE;
@@ -413,7 +414,9 @@ status_t CameraDeviceClient::createStream(
int streamId = -1;
res = mDevice->createStream(anw, width, height, format, dataSpace,
- &streamId);
+ static_cast<camera3_stream_rotation_t>
+ (outputConfiguration.getRotation()),
+ &streamId);
if (res == OK) {
mStreamMap.add(binder, streamId);
diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.h b/services/camera/libcameraservice/api2/CameraDeviceClient.h
index c89c269..a3dbb90 100644
--- a/services/camera/libcameraservice/api2/CameraDeviceClient.h
+++ b/services/camera/libcameraservice/api2/CameraDeviceClient.h
@@ -19,6 +19,7 @@
#include <camera/camera2/ICameraDeviceUser.h>
#include <camera/camera2/ICameraDeviceCallbacks.h>
+#include <camera/camera2/OutputConfiguration.h>
#include "CameraService.h"
#include "common/FrameProcessorBase.h"
@@ -83,8 +84,7 @@ public:
// Returns -EBUSY if device is not idle
virtual status_t deleteStream(int streamId);
- virtual status_t createStream(
- const sp<IGraphicBufferProducer>& bufferProducer);
+ virtual status_t createStream(const OutputConfiguration &outputConfiguration);
// Create a request object from a template.
virtual status_t createDefaultRequest(int templateId,
diff --git a/services/camera/libcameraservice/api_pro/ProCamera2Client.cpp b/services/camera/libcameraservice/api_pro/ProCamera2Client.cpp
index ba93554..a977494 100644
--- a/services/camera/libcameraservice/api_pro/ProCamera2Client.cpp
+++ b/services/camera/libcameraservice/api_pro/ProCamera2Client.cpp
@@ -281,7 +281,8 @@ status_t ProCamera2Client::createStream(int width, int height, int format,
}
return mDevice->createStream(window, width, height, format,
- HAL_DATASPACE_UNKNOWN, streamId);
+ HAL_DATASPACE_UNKNOWN, CAMERA3_STREAM_ROTATION_0,
+ streamId);
}
// Create a request object from a template.
diff --git a/services/camera/libcameraservice/common/CameraDeviceBase.h b/services/camera/libcameraservice/common/CameraDeviceBase.h
index 8764504..fe55b9e 100644
--- a/services/camera/libcameraservice/common/CameraDeviceBase.h
+++ b/services/camera/libcameraservice/common/CameraDeviceBase.h
@@ -100,14 +100,14 @@ class CameraDeviceBase : public virtual RefBase {
nsecs_t timeout) = 0;
/**
- * Create an output stream of the requested size, format, and dataspace
+ * Create an output stream of the requested size, format, rotation and dataspace
*
* For HAL_PIXEL_FORMAT_BLOB formats, the width and height should be the
* logical dimensions of the buffer, not the number of bytes.
*/
virtual status_t createStream(sp<ANativeWindow> consumer,
uint32_t width, uint32_t height, int format,
- android_dataspace dataSpace, int *id) = 0;
+ android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id) = 0;
/**
* Create an input reprocess stream that uses buffers from an existing
diff --git a/services/camera/libcameraservice/device2/Camera2Device.cpp b/services/camera/libcameraservice/device2/Camera2Device.cpp
index ee862a2..878986b 100644
--- a/services/camera/libcameraservice/device2/Camera2Device.cpp
+++ b/services/camera/libcameraservice/device2/Camera2Device.cpp
@@ -242,7 +242,7 @@ status_t Camera2Device::waitUntilRequestReceived(int32_t requestId, nsecs_t time
status_t Camera2Device::createStream(sp<ANativeWindow> consumer,
uint32_t width, uint32_t height, int format,
- android_dataspace /*dataSpace*/, int *id) {
+ android_dataspace /*dataSpace*/, camera3_stream_rotation_t rotation, int *id) {
ATRACE_CALL();
status_t res;
ALOGV("%s: E", __FUNCTION__);
diff --git a/services/camera/libcameraservice/device2/Camera2Device.h b/services/camera/libcameraservice/device2/Camera2Device.h
index e4c2856..9b32fa6 100644
--- a/services/camera/libcameraservice/device2/Camera2Device.h
+++ b/services/camera/libcameraservice/device2/Camera2Device.h
@@ -58,7 +58,7 @@ class Camera2Device: public CameraDeviceBase {
virtual status_t waitUntilRequestReceived(int32_t requestId, nsecs_t timeout);
virtual status_t createStream(sp<ANativeWindow> consumer,
uint32_t width, uint32_t height, int format,
- android_dataspace dataSpace, int *id);
+ android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id);
virtual status_t createReprocessStreamFromStream(int outputId, int *id);
virtual status_t getStreamInfo(int id,
uint32_t *width, uint32_t *height, uint32_t *format);
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index 529d249..8236788 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -802,12 +802,12 @@ status_t Camera3Device::createZslStream(
status_t Camera3Device::createStream(sp<ANativeWindow> consumer,
uint32_t width, uint32_t height, int format, android_dataspace dataSpace,
- int *id) {
+ camera3_stream_rotation_t rotation, int *id) {
ATRACE_CALL();
Mutex::Autolock il(mInterfaceLock);
Mutex::Autolock l(mLock);
- ALOGV("Camera %d: Creating new stream %d: %d x %d, format %d, dataspace %d",
- mId, mNextStreamId, width, height, format, dataSpace);
+ ALOGV("Camera %d: Creating new stream %d: %d x %d, format %d, dataspace %d rotation %d",
+ mId, mNextStreamId, width, height, format, dataSpace, rotation);
status_t res;
bool wasActive = false;
@@ -847,10 +847,10 @@ status_t Camera3Device::createStream(sp<ANativeWindow> consumer,
}
newStream = new Camera3OutputStream(mNextStreamId, consumer,
- width, height, jpegBufferSize, format, dataSpace);
+ width, height, jpegBufferSize, format, dataSpace, rotation);
} else {
newStream = new Camera3OutputStream(mNextStreamId, consumer,
- width, height, format, dataSpace);
+ width, height, format, dataSpace, rotation);
}
newStream->setStatusTracker(mStatusTracker);
diff --git a/services/camera/libcameraservice/device3/Camera3Device.h b/services/camera/libcameraservice/device3/Camera3Device.h
index e2ad1fa..a77548d 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.h
+++ b/services/camera/libcameraservice/device3/Camera3Device.h
@@ -96,7 +96,7 @@ class Camera3Device :
// stream, reconfiguring device, and unpausing.
virtual status_t createStream(sp<ANativeWindow> consumer,
uint32_t width, uint32_t height, int format,
- android_dataspace dataSpace, int *id);
+ android_dataspace dataSpace, camera3_stream_rotation_t rotation, int *id);
virtual status_t createInputStream(
uint32_t width, uint32_t height, int format,
int *id);
diff --git a/services/camera/libcameraservice/device3/Camera3DummyStream.cpp b/services/camera/libcameraservice/device3/Camera3DummyStream.cpp
index 6201484..01edfff 100644
--- a/services/camera/libcameraservice/device3/Camera3DummyStream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3DummyStream.cpp
@@ -28,7 +28,7 @@ namespace camera3 {
Camera3DummyStream::Camera3DummyStream(int id) :
Camera3IOStreamBase(id, CAMERA3_STREAM_OUTPUT, DUMMY_WIDTH, DUMMY_HEIGHT,
- /*maxSize*/0, DUMMY_FORMAT, DUMMY_DATASPACE) {
+ /*maxSize*/0, DUMMY_FORMAT, DUMMY_DATASPACE, DUMMY_ROTATION) {
}
diff --git a/services/camera/libcameraservice/device3/Camera3DummyStream.h b/services/camera/libcameraservice/device3/Camera3DummyStream.h
index 7f52d84..d023c57 100644
--- a/services/camera/libcameraservice/device3/Camera3DummyStream.h
+++ b/services/camera/libcameraservice/device3/Camera3DummyStream.h
@@ -76,6 +76,7 @@ class Camera3DummyStream :
static const int DUMMY_HEIGHT = 240;
static const int DUMMY_FORMAT = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
static const android_dataspace DUMMY_DATASPACE = HAL_DATASPACE_UNKNOWN;
+ static const camera3_stream_rotation_t DUMMY_ROTATION = CAMERA3_STREAM_ROTATION_0;
static const uint32_t DUMMY_USAGE = GRALLOC_USAGE_HW_COMPOSER;
/**
diff --git a/services/camera/libcameraservice/device3/Camera3IOStreamBase.cpp b/services/camera/libcameraservice/device3/Camera3IOStreamBase.cpp
index ff0acbb..8696413 100644
--- a/services/camera/libcameraservice/device3/Camera3IOStreamBase.cpp
+++ b/services/camera/libcameraservice/device3/Camera3IOStreamBase.cpp
@@ -31,9 +31,9 @@ namespace camera3 {
Camera3IOStreamBase::Camera3IOStreamBase(int id, camera3_stream_type_t type,
uint32_t width, uint32_t height, size_t maxSize, int format,
- android_dataspace dataSpace) :
+ android_dataspace dataSpace, camera3_stream_rotation_t rotation) :
Camera3Stream(id, type,
- width, height, maxSize, format, dataSpace),
+ width, height, maxSize, format, dataSpace, rotation),
mTotalBufferCount(0),
mHandoutTotalBufferCount(0),
mHandoutOutputBufferCount(0),
diff --git a/services/camera/libcameraservice/device3/Camera3IOStreamBase.h b/services/camera/libcameraservice/device3/Camera3IOStreamBase.h
index 83d4350..abcf2b1 100644
--- a/services/camera/libcameraservice/device3/Camera3IOStreamBase.h
+++ b/services/camera/libcameraservice/device3/Camera3IOStreamBase.h
@@ -34,7 +34,7 @@ class Camera3IOStreamBase :
protected:
Camera3IOStreamBase(int id, camera3_stream_type_t type,
uint32_t width, uint32_t height, size_t maxSize, int format,
- android_dataspace dataSpace);
+ android_dataspace dataSpace, camera3_stream_rotation_t rotation);
public:
diff --git a/services/camera/libcameraservice/device3/Camera3InputStream.cpp b/services/camera/libcameraservice/device3/Camera3InputStream.cpp
index 87907bf..6bf671e 100644
--- a/services/camera/libcameraservice/device3/Camera3InputStream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3InputStream.cpp
@@ -29,8 +29,8 @@ namespace camera3 {
Camera3InputStream::Camera3InputStream(int id,
uint32_t width, uint32_t height, int format) :
- Camera3IOStreamBase(id, CAMERA3_STREAM_INPUT, width, height,
- /*maxSize*/0, format, HAL_DATASPACE_UNKNOWN) {
+ Camera3IOStreamBase(id, CAMERA3_STREAM_INPUT, width, height, /*maxSize*/0,
+ format, HAL_DATASPACE_UNKNOWN, CAMERA3_STREAM_ROTATION_0) {
if (format == HAL_PIXEL_FORMAT_BLOB) {
ALOGE("%s: Bad format, BLOB not supported", __FUNCTION__);
diff --git a/services/camera/libcameraservice/device3/Camera3OutputStream.cpp b/services/camera/libcameraservice/device3/Camera3OutputStream.cpp
index 103d90b..96bed0d 100644
--- a/services/camera/libcameraservice/device3/Camera3OutputStream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3OutputStream.cpp
@@ -34,9 +34,9 @@ namespace camera3 {
Camera3OutputStream::Camera3OutputStream(int id,
sp<ANativeWindow> consumer,
uint32_t width, uint32_t height, int format,
- android_dataspace dataSpace) :
+ android_dataspace dataSpace, camera3_stream_rotation_t rotation) :
Camera3IOStreamBase(id, CAMERA3_STREAM_OUTPUT, width, height,
- /*maxSize*/0, format, dataSpace),
+ /*maxSize*/0, format, dataSpace, rotation),
mConsumer(consumer),
mTransform(0),
mTraceFirstBuffer(true) {
@@ -50,9 +50,9 @@ Camera3OutputStream::Camera3OutputStream(int id,
Camera3OutputStream::Camera3OutputStream(int id,
sp<ANativeWindow> consumer,
uint32_t width, uint32_t height, size_t maxSize, int format,
- android_dataspace dataSpace) :
+ android_dataspace dataSpace, camera3_stream_rotation_t rotation) :
Camera3IOStreamBase(id, CAMERA3_STREAM_OUTPUT, width, height, maxSize,
- format, dataSpace),
+ format, dataSpace, rotation),
mConsumer(consumer),
mTransform(0),
mTraceFirstBuffer(true) {
@@ -72,10 +72,11 @@ Camera3OutputStream::Camera3OutputStream(int id,
Camera3OutputStream::Camera3OutputStream(int id, camera3_stream_type_t type,
uint32_t width, uint32_t height,
int format,
- android_dataspace dataSpace) :
+ android_dataspace dataSpace,
+ camera3_stream_rotation_t rotation) :
Camera3IOStreamBase(id, type, width, height,
/*maxSize*/0,
- format, dataSpace),
+ format, dataSpace, rotation),
mTransform(0) {
// Subclasses expected to initialize mConsumer themselves
diff --git a/services/camera/libcameraservice/device3/Camera3OutputStream.h b/services/camera/libcameraservice/device3/Camera3OutputStream.h
index f016d60..12b2ebb 100644
--- a/services/camera/libcameraservice/device3/Camera3OutputStream.h
+++ b/services/camera/libcameraservice/device3/Camera3OutputStream.h
@@ -40,7 +40,7 @@ class Camera3OutputStream :
*/
Camera3OutputStream(int id, sp<ANativeWindow> consumer,
uint32_t width, uint32_t height, int format,
- android_dataspace dataSpace);
+ android_dataspace dataSpace, camera3_stream_rotation_t rotation);
/**
* Set up a stream for formats that have a variable buffer size for the same
@@ -48,7 +48,7 @@ class Camera3OutputStream :
*/
Camera3OutputStream(int id, sp<ANativeWindow> consumer,
uint32_t width, uint32_t height, size_t maxSize, int format,
- android_dataspace dataSpace);
+ android_dataspace dataSpace, camera3_stream_rotation_t rotation);
virtual ~Camera3OutputStream();
@@ -67,7 +67,7 @@ class Camera3OutputStream :
protected:
Camera3OutputStream(int id, camera3_stream_type_t type,
uint32_t width, uint32_t height, int format,
- android_dataspace dataSpace);
+ android_dataspace dataSpace, camera3_stream_rotation_t rotation);
/**
* Note that we release the lock briefly in this function
diff --git a/services/camera/libcameraservice/device3/Camera3Stream.cpp b/services/camera/libcameraservice/device3/Camera3Stream.cpp
index f829741..4acbce3 100644
--- a/services/camera/libcameraservice/device3/Camera3Stream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Stream.cpp
@@ -47,7 +47,7 @@ const Camera3Stream* Camera3Stream::cast(const camera3_stream *stream) {
Camera3Stream::Camera3Stream(int id,
camera3_stream_type type,
uint32_t width, uint32_t height, size_t maxSize, int format,
- android_dataspace dataSpace) :
+ android_dataspace dataSpace, camera3_stream_rotation_t rotation) :
camera3_stream(),
mId(id),
mName(String8::format("Camera3Stream[%d]", id)),
@@ -60,6 +60,7 @@ Camera3Stream::Camera3Stream(int id,
camera3_stream::height = height;
camera3_stream::format = format;
camera3_stream::data_space = dataSpace;
+ camera3_stream::rotation = rotation;
camera3_stream::usage = 0;
camera3_stream::max_buffers = 0;
camera3_stream::priv = NULL;
diff --git a/services/camera/libcameraservice/device3/Camera3Stream.h b/services/camera/libcameraservice/device3/Camera3Stream.h
index 72f3ee9..aba27fe 100644
--- a/services/camera/libcameraservice/device3/Camera3Stream.h
+++ b/services/camera/libcameraservice/device3/Camera3Stream.h
@@ -266,7 +266,7 @@ class Camera3Stream :
Camera3Stream(int id, camera3_stream_type type,
uint32_t width, uint32_t height, size_t maxSize, int format,
- android_dataspace dataSpace);
+ android_dataspace dataSpace, camera3_stream_rotation_t rotation);
/**
* Interface to be implemented by derived classes
diff --git a/services/camera/libcameraservice/device3/Camera3ZslStream.cpp b/services/camera/libcameraservice/device3/Camera3ZslStream.cpp
index 5bf7a4c..10d7f2e 100644
--- a/services/camera/libcameraservice/device3/Camera3ZslStream.cpp
+++ b/services/camera/libcameraservice/device3/Camera3ZslStream.cpp
@@ -115,7 +115,7 @@ Camera3ZslStream::Camera3ZslStream(int id, uint32_t width, uint32_t height,
Camera3OutputStream(id, CAMERA3_STREAM_BIDIRECTIONAL,
width, height,
HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED,
- HAL_DATASPACE_UNKNOWN),
+ HAL_DATASPACE_UNKNOWN, CAMERA3_STREAM_ROTATION_0),
mDepth(bufferCount) {
sp<IGraphicBufferProducer> producer;
diff --git a/services/radio/Android.mk b/services/radio/Android.mk
index 5e89b22..9ee5666 100644
--- a/services/radio/Android.mk
+++ b/services/radio/Android.mk
@@ -26,6 +26,7 @@ LOCAL_SHARED_LIBRARIES:= \
libutils \
libbinder \
libcutils \
+ libmedia \
libhardware \
libradio \
libradio_metadata
diff --git a/services/radio/RadioService.cpp b/services/radio/RadioService.cpp
index 152619b..a6c2bdf 100644
--- a/services/radio/RadioService.cpp
+++ b/services/radio/RadioService.cpp
@@ -22,6 +22,8 @@
#include <sys/types.h>
#include <pthread.h>
+#include <system/audio.h>
+#include <system/audio_policy.h>
#include <system/radio.h>
#include <system/radio_metadata.h>
#include <cutils/atomic.h>
@@ -33,11 +35,13 @@
#include <binder/MemoryBase.h>
#include <binder/MemoryHeapBase.h>
#include <hardware/radio.h>
+#include <media/AudioSystem.h>
#include "RadioService.h"
#include "RadioRegions.h"
namespace android {
+static const char kRadioTunerAudioDeviceName[] = "Radio tuner source";
RadioService::RadioService()
: BnRadioService(), mNextUniqueId(1)
@@ -84,7 +88,7 @@ void RadioService::onFirstRef()
ALOGI("loaded default module %s, handle %d", properties.product, properties.handle);
convertProperties(&properties, &halProperties);
- sp<Module> module = new Module(this, dev, properties);
+ sp<Module> module = new Module(dev, properties);
mModules.add(properties.handle, module);
}
@@ -380,10 +384,8 @@ void RadioService::CallbackThread::sendEvent(radio_hal_event_t *event)
#undef LOG_TAG
#define LOG_TAG "RadioService::Module"
-RadioService::Module::Module(const sp<RadioService>& service,
- radio_hw_device* hwDevice,
- radio_properties properties)
- : mService(service), mHwDevice(hwDevice), mProperties(properties), mMute(true)
+RadioService::Module::Module(radio_hw_device* hwDevice, radio_properties properties)
+ : mHwDevice(hwDevice), mProperties(properties), mMute(true)
{
}
@@ -416,6 +418,31 @@ sp<RadioService::ModuleClient> RadioService::Module::addClient(const sp<IRadioCl
struct radio_hal_band_config halConfig;
halConfig = config->band;
+ // Tuner preemption logic:
+ // There is a limited amount of tuners and a limited amount of radio audio sources per module.
+ // The minimum is one tuner and one audio source.
+ // The numbers of tuners and sources are indicated in the module properties.
+ // NOTE: current framework implementation only supports one radio audio source.
+ // It is possible to open more than one tuner at a time but only one tuner can be connected
+ // to the radio audio source (AUDIO_DEVICE_IN_FM_TUNER).
+ // The base rule is that a newly connected tuner always wins, i.e. always gets a tuner
+ // and can use the audio source if requested.
+ // If another client is preempted, it is notified by a callback with RADIO_EVENT_CONTROL
+ // indicating loss of control.
+ // - If the newly connected client requests the audio source (audio == true):
+ // - if an audio source is available
+ // no problem
+ // - if not:
+ // the oldest client in the list using audio is preempted.
+ // - If the newly connected client does not request the audio source (audio == false):
+ // - if a tuner is available
+ // no problem
+ // - if not:
+ // The oldest client not using audio is preempted first and if none is found the
+ // the oldest client using audio is preempted.
+ // Each time a tuner using the audio source is opened or closed, the audio policy manager is
+ // notified of the connection or disconnection of AUDIO_DEVICE_IN_FM_TUNER.
+
sp<ModuleClient> oldestTuner;
sp<ModuleClient> oldestAudio;
size_t allocatedTuners = 0;
@@ -437,28 +464,31 @@ sp<RadioService::ModuleClient> RadioService::Module::addClient(const sp<IRadioCl
}
const struct radio_tuner *halTuner;
+ sp<ModuleClient> preemtedClient;
if (audio) {
if (allocatedAudio >= mProperties.num_audio_sources) {
ALOG_ASSERT(oldestAudio != 0, "addClient() allocatedAudio/oldestAudio mismatch");
- halTuner = oldestAudio->getTuner();
- oldestAudio->setTuner(NULL);
- mHwDevice->close_tuner(mHwDevice, halTuner);
+ preemtedClient = oldestAudio;
}
} else {
if (allocatedAudio + allocatedTuners >= mProperties.num_tuners) {
if (allocatedTuners != 0) {
ALOG_ASSERT(oldestTuner != 0, "addClient() allocatedTuners/oldestTuner mismatch");
- halTuner = oldestTuner->getTuner();
- oldestTuner->setTuner(NULL);
- mHwDevice->close_tuner(mHwDevice, halTuner);
+ preemtedClient = oldestTuner;
} else {
ALOG_ASSERT(oldestAudio != 0, "addClient() allocatedAudio/oldestAudio mismatch");
- halTuner = oldestAudio->getTuner();
- oldestAudio->setTuner(NULL);
- mHwDevice->close_tuner(mHwDevice, halTuner);
+ preemtedClient = oldestAudio;
}
}
}
+ if (preemtedClient != 0) {
+ halTuner = preemtedClient->getTuner();
+ preemtedClient->setTuner(NULL);
+ mHwDevice->close_tuner(mHwDevice, halTuner);
+ if (preemtedClient->audio()) {
+ notifyDeviceConnection(false, "");
+ }
+ }
ret = mHwDevice->open_tuner(mHwDevice, &halConfig, audio,
RadioService::callback, moduleClient->callbackThread().get(),
@@ -467,11 +497,13 @@ sp<RadioService::ModuleClient> RadioService::Module::addClient(const sp<IRadioCl
ALOGV("addClient() setTuner %p", halTuner);
moduleClient->setTuner(halTuner);
mModuleClients.add(moduleClient);
+ if (audio) {
+ notifyDeviceConnection(true, "");
+ }
} else {
moduleClient.clear();
}
- //TODO notify audio device connection to audio policy manager if audio is on
ALOGV("addClient() DONE moduleClient %p", moduleClient.get());
@@ -501,19 +533,32 @@ void RadioService::Module::removeClient(const sp<ModuleClient>& moduleClient) {
}
mHwDevice->close_tuner(mHwDevice, halTuner);
+ if (moduleClient->audio()) {
+ notifyDeviceConnection(false, "");
+ }
- //TODO notify audio device disconnection to audio policy manager if audio was on
mMute = true;
if (mModuleClients.isEmpty()) {
return;
}
+ // Tuner reallocation logic:
+ // When a client is removed and was controlling a tuner, this tuner will be allocated to a
+ // previously preempted client. This client will be notified by a callback with
+ // RADIO_EVENT_CONTROL indicating gain of control.
+ // - If a preempted client is waiting for an audio source and one becomes available:
+ // Allocate the tuner to the most recently added client waiting for an audio source
+ // - If not:
+ // Allocate the tuner to the most recently added client.
+ // Each time a tuner using the audio source is opened or closed, the audio policy manager is
+ // notified of the connection or disconnection of AUDIO_DEVICE_IN_FM_TUNER.
+
sp<ModuleClient> youngestClient;
sp<ModuleClient> youngestClientAudio;
size_t allocatedTuners = 0;
size_t allocatedAudio = 0;
- for (ssize_t i = mModuleClients.size(); i >= 0; i--) {
+ for (ssize_t i = mModuleClients.size() - 1; i >= 0; i--) {
if (mModuleClients[i]->getTuner() == NULL) {
if (mModuleClients[i]->audio()) {
if (youngestClientAudio == 0) {
@@ -550,10 +595,11 @@ void RadioService::Module::removeClient(const sp<ModuleClient>& moduleClient) {
RadioService::callback, moduleClient->callbackThread().get(),
&halTuner);
- //TODO notify audio device connection to audio policy manager if audio is on
-
if (ret == 0) {
youngestClient->setTuner(halTuner);
+ if (youngestClient->audio()) {
+ notifyDeviceConnection(true, "");
+ }
}
}
@@ -583,6 +629,16 @@ const struct radio_band_config *RadioService::Module::getDefaultConfig() const
return &mProperties.bands[0];
}
+void RadioService::Module::notifyDeviceConnection(bool connected,
+ const char *address) {
+ int64_t token = IPCThreadState::self()->clearCallingIdentity();
+ AudioSystem::setDeviceConnectionState(AUDIO_DEVICE_IN_FM_TUNER,
+ connected ? AUDIO_POLICY_DEVICE_STATE_AVAILABLE :
+ AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
+ address, kRadioTunerAudioDeviceName);
+ IPCThreadState::self()->restoreCallingIdentity(token);
+}
+
#undef LOG_TAG
#define LOG_TAG "RadioService::ModuleClient"
diff --git a/services/radio/RadioService.h b/services/radio/RadioService.h
index 9ede020..49feda6 100644
--- a/services/radio/RadioService.h
+++ b/services/radio/RadioService.h
@@ -66,8 +66,7 @@ public:
class Module : public virtual RefBase {
public:
- Module(const sp<RadioService>& service,
- radio_hw_device* hwDevice,
+ Module(radio_hw_device* hwDevice,
struct radio_properties properties);
virtual ~Module();
@@ -88,16 +87,17 @@ public:
const struct radio_properties properties() const { return mProperties; }
const struct radio_band_config *getDefaultConfig() const ;
- wp<RadioService> service() const { return mService; }
-
private:
- Mutex mLock;
- wp<RadioService> mService;
- const struct radio_hw_device *mHwDevice;
- const struct radio_properties mProperties;
- Vector< sp<ModuleClient> > mModuleClients;
- bool mMute;
+ void notifyDeviceConnection(bool connected, const char *address);
+
+ Mutex mLock; // protects mModuleClients
+ const struct radio_hw_device *mHwDevice; // HAL hardware device
+ const struct radio_properties mProperties; // cached hardware module properties
+ Vector< sp<ModuleClient> > mModuleClients; // list of attached clients
+ bool mMute; // radio audio source state
+ // when unmuted, audio is routed to the
+ // output device selected for media use case.
}; // class Module
class CallbackThread : public Thread {
@@ -120,11 +120,11 @@ public:
sp<IMemory> prepareEvent(radio_hal_event_t *halEvent);
private:
- wp<ModuleClient> mModuleClient;
- Condition mCallbackCond;
- Mutex mCallbackLock;
- Vector< sp<IMemory> > mEventQueue;
- sp<MemoryDealer> mMemoryDealer;
+ wp<ModuleClient> mModuleClient; // client module the thread belongs to
+ Condition mCallbackCond; // condition signaled when a new event is posted
+ Mutex mCallbackLock; // protects mEventQueue
+ Vector< sp<IMemory> > mEventQueue; // pending callback events
+ sp<MemoryDealer> mMemoryDealer; // shared memory for callback event
}; // class CallbackThread
class ModuleClient : public BnRadio,
@@ -181,13 +181,15 @@ public:
private:
- mutable Mutex mLock;
- wp<Module> mModule;
- sp<IRadioClient> mClient;
- radio_band_config_t mConfig;
- sp<CallbackThread> mCallbackThread;
+ mutable Mutex mLock; // protects mClient, mConfig and mTuner
+ wp<Module> mModule; // The module this client is attached to
+ sp<IRadioClient> mClient; // event callback binder interface
+ radio_band_config_t mConfig; // current band configuration
+ sp<CallbackThread> mCallbackThread; // event callback thread
const bool mAudio;
- const struct radio_tuner *mTuner;
+ const struct radio_tuner *mTuner; // HAL tuner interface. NULL indicates that
+ // this client does not have control on any
+ // tuner
}; // class ModuleClient
@@ -199,8 +201,8 @@ private:
static void convertProperties(radio_properties_t *properties,
const radio_hal_properties_t *halProperties);
- Mutex mServiceLock;
- volatile int32_t mNextUniqueId;
+ Mutex mServiceLock; // protects mModules
+ volatile int32_t mNextUniqueId; // for module ID allocation
DefaultKeyedVector< radio_handle_t, sp<Module> > mModules;
};