hdmi hotplug

本文详细解析了Android系统中HDMI热插拔(hotplug)事件的处理流程,从硬件检测到框架层回调,再到应用程序的响应。当HDMI设备插入或拔出时,系统通过tv_input模块检测并通知上层,导致设备可用或不可用事件的触发,进而影响到TV Input服务及App的显示状态。通过对关键代码的跟踪,展示了设备状态变化如何在不同层级间传递,最后影响到用户界面的更新。
摘要由CSDN通过智能技术生成

hdmi插入,信号源app hdmi连接logo显示

hdmi拔掉,信号源app hdmi连接logo不显示

代码流程分析。

一,

hdmi在插入时,5v检测会探测到是哪个hdmi插入的。

我猜测tv_input.amlogic.so会一直read这个状态。

 

tv_input( 4331): TvCallback::onTvEvent  source = 7, status = 0

hdmi拔掉的时候,amlogic不开源的tv_input.amlogic.so向上层callback一个消息。source=7 代表是hdmi3,status = 0代表拔掉。

 

vendor/amlogic/apps/TvLibRelease/tv_input/tv_input.cpp

 

static int notify_HDMI_device_available(tv_input_private_t *priv, tv_source_input_t source_input, uint32_t port_id, int type)
{
        tv_input_event_t event;
        event.device_info.device_id = source_input;
        event.device_info.type = TV_INPUT_TYPE_HDMI;
        event.type = type;
        event.device_info.hdmi.port_id = port_id;
        event.device_info.audio_type = AUDIO_DEVICE_NONE;
        event.device_info.audio_address = NULL;
        priv->callback->notify(&priv->device, &event, priv->callback_data);
        return 0;
}

 

二,frameworks/base/services/core/jni/com_android_server_tv_TvInputHal.cpp  

void JTvInputHal::notify(
        tv_input_device_t* dev, tv_input_event_t* event, void* data) {
    JTvInputHal* thiz = (JTvInputHal*)data;
    ALOGE("JTvInputHal notify sendMessage"+event->type);
    thiz->mLooper->sendMessage(new NotifyHandler(thiz, event), event->type);
}

 

void JTvInputHal::NotifyHandler::handleMessage(const Message& message) {
    switch (mEvent.type) {
        case TV_INPUT_EVENT_DEVICE_AVAILABLE: {
            mHal->onDeviceAvailable(mEvent.device_info);
        } break;
        case TV_INPUT_EVENT_DEVICE_UNAVAILABLE: {
            ALOGE("TV_INPUT_EVENT_DEVICE_UNAVAILABLE device_id"+mEvent.device_info.device_id);
                                                        mHal->onDeviceUnavailable(mEvent.device_info.device_id);
        } break;
        case TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED: {
            mHal->onStreamConfigurationsChanged(mEvent.device_info.device_id);
        } break;
        case TV_INPUT_EVENT_CAPTURE_SUCCEEDED: {
            mHal->onCaptured(mEvent.capture_result.device_id,
                             mEvent.capture_result.stream_id,
                             mEvent.capture_result.seq,
                             true /* succeeded */);
        } break;
        case TV_INPUT_EVENT_CAPTURE_FAILED: {
            mHal->onCaptured(mEvent.capture_result.device_id,
                             mEvent.capture_result.stream_id,
                             mEvent.capture_result.seq,
                             false /* succeeded */);
        } break;
        default:
            ALOGE("Unrecognizable event");
    }
}

 

走到这,  case TV_INPUT_EVENT_DEVICE_UNAVAILABLE: {
            ALOGE("TV_INPUT_EVENT_DEVICE_UNAVAILABLE device_id"+mEvent.device_info.device_id);
                                                        mHal->onDeviceUnavailable(mEvent.device_info.device_id);
        } break;


void JTvInputHal::onDeviceUnavailable(int deviceId) {
    {
        Mutex::Autolock autoLock(&mLock);
        KeyedVector<int, Connection>& connections = mConnections.editValueFor(deviceId);
        for (size_t i = 0; i < connections.size(); ++i) {
            removeStream(deviceId, connections.keyAt(i));
        }
        connections.clear();
        mConnections.removeItem(deviceId);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值