android/device/softwinner/ceres-c3/ceres_c3.mk
.. .. @@ -328,6 +328,16 @@ 328 328 329 329 #PRODUCT_ROTATION := 90 330 330 331 +PRODUCT_HAS_UVC_CAMERA := true332 +ifeq ($(PRODUCT_HAS_UVC_CAMERA),true)333 +PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \334 + ro.camera.uvcfacing=external335 +336 +PRODUCT_COPY_FILES += \337 + device/softwinner/common/config/external_camera_config.xml:$(TARGET_COPY_OUT_VENDOR)/etc/external_camera_config.xml338 +endif339 +340 +331 341 PRODUCT_COPY_FILES += \ 332 342 $(LOCAL_PATH)/ido/liblcd_bl.so:/system/lib64/liblcd_bl.so \ 333 343 $(LOCAL_PATH)/ido/liblcd_bl32.so:/system/lib/liblcd_bl.so \ android/device/softwinner/ceres-c3/configs/manifest.xml
.. .. @@ -156,6 +156,7 @@ 156 156 <interface> 157 157 <name>ICameraProvider</name> 158 158 <instance>legacy/0</instance> 159 + <instance>external/0</instance>159 160 </interface> 160 161 </hal> 161 162 <hal format="hidl"> android/device/softwinner/ceres-c3/configs/media_profiles.xml
.. .. @@ -79,7 +79,33 @@ 79 79 <!-- Each camcorder profile defines a set of predefined configuration parameters --> 80 80 <!-- Back Camera --> 81 81 <!-- Front Camera --> 82 + <!-- External Camera -->82 83 <CamcorderProfiles cameraId="0" > 84 + <EncoderProfile quality="720p" fileFormat="mp4" duration="30">85 + <Video codec="h264"86 + bitRate="1500000"87 + width="1280"88 + height="720"89 + frameRate="30" />90 +91 + <Audio codec="aac"92 + bitRate="12200"93 + sampleRate="8000"94 + channels="1" />95 + </EncoderProfile>96 + <EncoderProfile quality="timelapse720p" fileFormat="mp4" duration="30">97 + <Video codec="h264"98 + bitRate="1500000"99 + width="1280"100 + height="720"101 + frameRate="30" />102 +103 + <Audio codec="aac"104 + bitRate="12200"105 + sampleRate="8000"106 + channels="1" />107 + </EncoderProfile>108 +83 109 <EncoderProfile quality="480p" fileFormat="mp4" duration="30"> 84 110 <Video codec="h264" 85 111 bitRate="1500000" .. .. @@ -148,6 +174,38 @@ 148 174 149 175 </CamcorderProfiles> 150 176 177 + <CamcorderProfiles cameraId="2" >178 + <EncoderProfile quality="480p" fileFormat="mp4" duration="30">179 + <Video codec="h264"180 + bitRate="1500000"181 + width="1280"182 + height="720"183 + frameRate="30" />184 +185 + <Audio codec="aac"186 + bitRate="12200"187 + sampleRate="8000"188 + channels="1" />189 + </EncoderProfile>190 + <EncoderProfile quality="timelapse480p" fileFormat="mp4" duration="30">191 + <Video codec="h264"192 + bitRate="1500000"193 + width="1280"194 + height="720"195 + frameRate="30" />196 +197 + <Audio codec="aac"198 + bitRate="12200"199 + sampleRate="8000"200 + channels="1" />201 + </EncoderProfile>202 +203 + <ImageEncoding quality="90" />204 + <ImageEncoding quality="80" />205 + <ImageEncoding quality="70" />206 + <ImageDecoding memCap="20000000" />207 + </CamcorderProfiles>208 +151 209 <EncoderOutputFileFormat name="mp4" /> 152 210 153 211 <!-- android/device/softwinner/ceres-c3/hal.mk
.. .. @@ -26,12 +26,16 @@ 26 26 27 27 # CAMERA 28 28 PRODUCT_PACKAGES += \ 29 - camera.device@3.2-impl \29 + camera.device@3.5-impl \30 30 android.hardware.camera.provider@2.4-service-lazy \ 31 31 android.hardware.camera.provider@2.4-impl \ 32 32 libcamera \ 33 33 camera.ceres 34 34 35 +PRODUCT_PACKAGES += \36 + android.hardware.camera.provider@2.4-external-service37 +38 +35 39 # Memtrack 36 40 PRODUCT_PACKAGES += \ 37 41 android.hardware.memtrack@1.0-impl \ android/device/softwinner/ceres-c3/init.device.rc
.. .. @@ -50,6 +50,10 @@ 50 50 insmod vendor/modules/ov8858_r2a_4lane.ko 51 51 #insmod /vendor/modules/gc2385_mipi.ko 52 52 insmod /vendor/modules/vin_v4l2.ko 53 +### uvc module54 + insmod /vendor/modules/videobuf2-vmalloc.ko55 + insmod /vendor/modules/uvcvideo.ko56 +53 57 54 58 on property:sys.boot_completed=1 55 59 #usb hub up android/hardware/interfaces/camera/device/3.4/default/ExternalCameraDeviceSession.cpp
.. .. @@ -2372,12 +2372,12 @@ 2372 2372 } 2373 2373 uint32_t bufferSize = fmt.fmt.pix.sizeimage; 2374 2374 ALOGI("%s: V4L2 buffer size is %d", __FUNCTION__, bufferSize); 2375 - uint32_t expectedMaxBufferSize = kMaxBytesPerPixel * fmt.fmt.pix.width * fmt.fmt.pix.height;2376 - if ((bufferSize == 0) || (bufferSize > expectedMaxBufferSize)) {2377 - ALOGE("%s: V4L2 buffer size: %u looks invalid. Expected maximum size: %u", __FUNCTION__,2378 - bufferSize, expectedMaxBufferSize);2379 - return -EINVAL;2380 - }2375 + //uint32_t expectedMaxBufferSize = kMaxBytesPerPixel * fmt.fmt.pix.width * fmt.fmt.pix.height;2376 + // if ((bufferSize == 0) || (bufferSize > expectedMaxBufferSize)) {2377 + // ALOGE("%s: V4L2 buffer size: %u looks invalid. Expected maximum size: %u", __FUNCTION__,2378 + // bufferSize, expectedMaxBufferSize);2379 + // return -EINVAL;2380 + // }2381 2381 mMaxV4L2BufferSize = bufferSize; 2382 2382 2383 2383 const double kDefaultFps = 30.0; android/packages/apps/Camera2/res/values/arrays.xml
.. .. @@ -169,21 +169,25 @@ 169 169 <array name="camera_id_entries" translatable="false"> 170 170 <item>@string/pref_camera_id_entry_back</item> 171 171 <item>@string/pref_camera_id_entry_front</item> 172 + <item>@string/pref_camera_id_entry_external</item>172 173 </array> 173 174 174 175 <array name="camera_id_entryvalues" translatable="false"> 175 176 <item>@string/pref_camera_id_entry_back_value</item> 176 177 <item>@string/pref_camera_id_entry_front_value</item> 178 + <item>@string/pref_camera_id_entry_external_value</item>177 179 </array> 178 180 179 181 <array name="camera_id_labels" translatable="false"> 180 182 <item>@string/pref_camera_id_label_back</item> 181 183 <item>@string/pref_camera_id_label_front</item> 184 + <item>@string/pref_camera_id_label_external</item>182 185 </array> 183 186 184 187 <array name="camera_id_icons" translatable="false"> 185 188 <item>@drawable/ic_switch_camera_back</item> 186 189 <item>@drawable/ic_switch_camera_front</item> 190 + <item>@drawable/ic_switch_camera_external</item>187 191 </array> 188 192 189 193 <array name="camera_id_icons_without_external" translatable="false"> .. .. @@ -221,6 +225,7 @@ 221 225 <array name="camera_id_largeicons" translatable="false"> 222 226 <item>@drawable/ic_switch_camera_back</item> 223 227 <item>@drawable/ic_switch_camera_front</item> 228 + <item>@drawable/ic_switch_camera_external</item>224 229 </array> 225 230 226 231 <string-array name="pref_video_effect_entries" translatable="false"> android/packages/apps/Camera2/res/values/strings.xml
.. .. @@ -174,6 +174,7 @@ 174 174 <!-- Named indexes into the array of camera facing entries --> 175 175 <string name="pref_camera_id_index_back" translatable="false">1</string> 176 176 <string name="pref_camera_id_index_front" translatable="false">2</string> 177 + <string name="pref_camera_id_index_external" translatable="false">2</string>177 178 178 179 <!-- In select camera setting, back facing camera. [CHAR LIMIT=14] --> 179 180 <string name="pref_camera_id_entry_back">Back</string> .. .. @@ -185,6 +186,7 @@ 185 186 <string name="pref_camera_id_entry_back_value" translatable="false">0</string> 186 187 <!-- In select camera setting, front-facing camera value. [CHAR LIMIT=14] --> 187 188 <string name="pref_camera_id_entry_front_value" translatable="false">1</string> 189 + <string name="pref_camera_id_entry_external_value" translatable="false">2</string>188 190 189 191 <!-- Settings screen, location setting text. [CHAR LIMIT=20]--> 190 192 <string name="pref_camera_save_location_title">Save location</string> android/packages/apps/Camera2/src/com/android/camera/MultiToggleImageButton.java
.. .. @@ -27,6 +27,7 @@ 27 27 import android.graphics.Matrix; 28 28 import android.graphics.drawable.Drawable; 29 29 import android.os.AsyncTask; 30 +import android.os.SystemProperties;30 31 import android.util.AttributeSet; 31 32 import android.view.View; 32 33 import android.widget.ImageButton; .. .. @@ -74,6 +75,8 @@ 74 75 private int mAnimDirection; 75 76 private Matrix mMatrix = new Matrix(); 76 77 private ValueAnimator mAnimator; 78 +79 + private static final String ANDROID_UVC_PROPERTY = "ro.camera.uvcfacing";77 80 78 81 public MultiToggleImageButton(Context context) { 79 82 super(context); .. .. @@ -242,6 +245,37 @@ 242 245 243 246 private void nextState() { 244 247 int state = mState + 1; 248 + if(getId() == R.id.camera_toggle_button){249 + /*250 + *If ro.camera.uvcfacing is set, then skip the original facing state.251 + */252 + String uvcProperty = SystemProperties.get(ANDROID_UVC_PROPERTY, "");253 + if(uvcProperty.equals("")){254 + if(state == Integer.parseInt(getResources()255 + .getString(R.string.pref_camera_id_entry_external_value))){256 + state = state + 1;257 + }258 + }259 + else if (uvcProperty.equals("back")) {260 + if(state == Integer.parseInt(getResources()261 + .getString(R.string.pref_camera_id_entry_back_value))){262 + state = state + 1;263 + }264 + }265 + else if (uvcProperty.equals("front")) {266 + if(state == Integer.parseInt(getResources()267 + .getString(R.string.pref_camera_id_entry_front_value))){268 + state = state + 1;269 + }270 + }271 + else if (uvcProperty.equals("external")) {272 + int externalValue = Integer.parseInt(getResources().273 + getString(R.string.pref_camera_id_entry_external_value));274 + if(state != externalValue){275 + state = externalValue;276 + }277 + }278 + }245 279 if (state >= mImageIds.length) { 246 280 state = 0; 247 281 } android/packages/apps/Camera2/src/com/android/camera/one/config/OneCameraFeatureConfigCreator.java
.. .. @@ -28,6 +28,7 @@ 28 28 import com.android.camera.util.GservicesHelper; 29 29 import com.google.common.base.Function; 30 30 import com.google.common.base.Optional; 31 +import android.os.SystemProperties;31 32 32 33 /** 33 34 * Creates the OneCamera feature configurations for the GoogleCamera app. .. .. @@ -35,6 +36,7 @@ 35 36 public class OneCameraFeatureConfigCreator { 36 37 private static final Log.Tag TAG = new Log.Tag("OneCamFtrCnfgCrtr"); 37 38 39 + private static final String ANDROID_UVC_PROPERTY = "ro.camera.uvcfacing";38 40 /** 39 41 * Create the default camera feature config. 40 42 */ .. .. @@ -119,7 +121,14 @@ 119 121 // On LIMITED devices starting with L-MR1 we run a simple YUV 120 122 // capture mode. 121 123 if (supportedLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED) { 122 - return CaptureSupportLevel.LIMITED_JPEG;124 + // return CaptureSupportLevel.LIMITED_JPEG;125 + String uvcProperty = SystemProperties.get(ANDROID_UVC_PROPERTY, "");126 + if(uvcProperty.equals("")){127 + return CaptureSupportLevel.LIMITED_JPEG;128 + }129 + else{130 + return CaptureSupportLevel.LIMITED_YUV;131 + }123 132 } 124 133 125 134 // We should never get here. If we do, let's fall back to a mode