CameraService

onFirstRef

 mCameraProviderManager->initialize(this);

mServiceProxy->registerForNotifications( "",    this);

HardwareServiceInteractionProxy

若ICameraProvice 服务成功注册,则调用notification->onRegistration 回调

sp<hardware::camera::provider::V2_4::ICameraProvider> getService(

hardware::camera::provider::V2_4::ICameraProvider::getService(serviceName);

getService 函数调用则会返回ICameraProvider注册的服务。也就是HIDL_FETCH_ICameraProvider 返回实体

compose epic...

compose epic...

  addProviderLocked(kLegacyProviderName, /*expected*/ false);

  addProviderLocked(kExternalProviderName, /*expected*/ false); 在MTK 代码中,并未使用到legacy/0 ,与 external/0 ,而是使用了internal/0, 所以此两行在吗在这未起作用。

CameraService::pingCameraServiceProxy()

 mUidPolicy = new UidPolicy(this); &&  mUidPolicy->registerSelf()

mCameraProviderManager

//前面调用了registerForNotifications, 等待进程服务 camerahalserver 起来并调用了

registerPassthroughServiceImplementation<ICameraProvider>("internal/0"); 注册了 internal/0 的HDIL 服务,

并调用了HIDL_FETCH_ICameraProvider 创建了CameraProviderImpl(就是 ICameraProvider 服务实列)

hardware::Return<void> CameraProviderManager::onRegistration(

    const hardware::hidl_string& /*fqName*/,

    const hardware::hidl_string& name,

    bool /*preexisting*/) //

addProviderLocked(name);//name : internal/0

interface = mServiceProxy->getService(newProvider);

providerInfo = new ProviderInfo(newProvider, interface, this);

status_t res = providerInfo->initialize();

interface 就是hal CameraProviderImpl 实列

ProviderInfo->mInterface = interface ,

mInterface->setCallback(this);

mInterface->getCameraIdList([&status, &devices]

devices.push_back(cameraDeviceNames[i]);

 addDevice(device,hardware::camera::common::V1_0::CameraDeviceStatus::PRESENT, &id);

mProviders.push_back(providerInfo);

compose epic...

compose epic...

addListener

Status CameraService::connectDevice(

    const sp<hardware::camera2::ICameraDeviceCallbacks>& cameraCb,

    const String16& cameraId,

    const String16& clientPackageName,

    int clientUid,

    /*out*/

    sp<hardware::camera2::ICameraDeviceUser>* device)

connectHelper

ret = makeClient(this, cameraCb, clientPackageName,

        cameraId, api1CameraId, facing,

        clientPid, clientUid, getpid(), legacyMode,

        halVersion, deviceVersion, effectiveApiLevel,

        /*out*/&tmp)

 *client = new CameraDeviceClient(cameraService, tmp, packageName, cameraId,

            facing, clientPid, clientUid, servicePid);

client = static_cast<CLIENT*>(tmp.get());

client->initialize(mCameraProviderManager, mMonitorTags);

调用了CameraDevuceClient->initiaze

compose epic...

CameraProviderImpl

getCameraIdList(getCameraIdList_cb _hidl_cb)

 mManager->getDeviceNameList(deviceNameList);

//CameraDeviceManagerImpl

compose epic...

compose epic...

compose epic...

compose epic...

compose epic...

custom/mt6580/hal/imgsensor_src/sensorlist.cpp

CameraDeviceClient

  Camera2ClientBase(cameraService, remoteCallback, clientPackageName,

        cameraId, /*API1 camera ID*/ -1,

        cameraFacing, clientPid, clientUid, servicePid),

Camera2ClientBase

 mDevice = new Camera3Device(cameraId);

TClientBase

 Camera3Device mDevice = new Camera3Device(cameraId);

 mInputStream(),

 mStreamingRequestId(REQUEST_ID_NONE),

initialize

initializeImpl(manager, monitorTags);

manager 就是CameraService->mCameraProviderManager

Camera2ClientBase::initializeImpl

mDevice->initialize(providerPtr, monitorTags);

mDevice 就是Camera3Device

providerPtr 就是CameraService->mCameraProviderManager

class Camera3Device

initialize(sp<CameraProviderManager> manager, const String8& monitorTags) 

compose epic...

Camera3Device

initialize(sp<CameraProviderManager> manager, const String8& monitorTags) 

manager->openSession(mId.string(), this,

      /*out*/ &session);

//CameraProviderManager::openSession

compose epic...

compose epic...

CameraProviderManager

openSession(const std::string &id,

    const sp<hardware::camera::device::V3_2::ICameraDeviceCallback>& callback,

    sp<hardware::camera::device::V3_2::ICameraDeviceSession> *session)


  auto deviceInfo = findDeviceInfoLocked(id,

      /*minVersion*/ {3,0}, /*maxVersion*/ {4,0});

从前面CameraProviderManager::onRegistration 回调中

getCameraIdList中  addDevice 获取

 auto *deviceInfo3 = static_cast<ProviderInfo::DeviceInfo3*>(deviceInfo);

deviceInfo3->mInterface->open(callback, [&status, &session]

      (Status s, const sp<device::V3_2::ICameraDeviceSession>& cameraSession) {

        status = s;

        if (status == Status::OK) {

          *session = cameraSession;

        }

      });

//mInterface -- 指向 CameraProviderImpl ::getCameraDeviceInterface_V3_x

指向CameraProviderImpl::getCameraDeviceInterface()中

最终指向mVirEnumDeviceMap 中的对应 CameraDevice3Imp

getCameraDeviceInterface_V3_x

——》

getCameraDeviceInterface

auto status = mManager->getDeviceInterface(cameraDeviceName, pBaseDevice);

//pBaseDevice 就是需要返回的interface

CameraDeviceManagerBase getDeviceInterface

//实际就是 通过mVirEnumDeviceMap

中找到 CameraDevice3Impl, CameraDevice3Impl

就是返回interface

 auto const& pInfo = mVirtEnumDeviceMap.valueFor(deviceName);

 auto const& pDevice = pInfo->mVirtDevice;

pDevice->getDeviceInterfaceBase(rpDevice);

CameraDevice3Impl::

getDeviceInterfaceBase{

return this

}

compose epic...

mInterface->open

compose epic...

compose epic...

ProviderInfo

compose epic...

addDevice

compose epic...

addProviderLocked

compose epic...

compose epic...

CameraService_2

CameraService_2

2019-03-09 11:05:17 0 22
这里是评论

相关推荐