Lines Matching full:hdmi
10 #include <linux/hdmi.h>
17 #include <sound/hdmi-codec.h>
26 /* Recommended N values from HDMI specification, tables 7-1 to 7-3 */
38 * hdmi_recommended_n() - Return N value recommended by HDMI specification
104 int mtk_hdmi_audio_params(struct mtk_hdmi *hdmi, in mtk_hdmi_audio_params() argument
111 dev_dbg(hdmi->dev, "%s: %u Hz, %d bit, %d channels\n", __func__, in mtk_hdmi_audio_params()
114 if (!hdmi->bridge.encoder) in mtk_hdmi_audio_params()
131 dev_err(hdmi->dev, "channel[%d] not supported!\n", chan); in mtk_hdmi_audio_params()
145 dev_err(hdmi->dev, "rate[%d] not supported!\n", in mtk_hdmi_audio_params()
164 dev_err(hdmi->dev, "%s: Invalid DAI format %d\n", __func__, in mtk_hdmi_audio_params()
169 memcpy(&hdmi->aud_param, &aud_params, sizeof(aud_params)); in mtk_hdmi_audio_params()
171 dev_dbg(hdmi->dev, "codec:%d, input:%d, channel:%d, fs:%d\n", in mtk_hdmi_audio_params()
181 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_audio_get_eld() local
183 if (hdmi->enabled) in mtk_hdmi_audio_get_eld()
184 memcpy(buf, hdmi->curr_conn->eld, min(sizeof(hdmi->curr_conn->eld), len)); in mtk_hdmi_audio_get_eld()
192 void mtk_hdmi_audio_set_plugged_cb(struct mtk_hdmi *hdmi, hdmi_codec_plugged_cb fn, in mtk_hdmi_audio_set_plugged_cb() argument
195 mutex_lock(&hdmi->update_plugged_status_lock); in mtk_hdmi_audio_set_plugged_cb()
196 hdmi->plugged_cb = fn; in mtk_hdmi_audio_set_plugged_cb()
197 hdmi->codec_dev = codec_dev; in mtk_hdmi_audio_set_plugged_cb()
198 mutex_unlock(&hdmi->update_plugged_status_lock); in mtk_hdmi_audio_set_plugged_cb()
202 static int mtk_hdmi_get_all_clk(struct mtk_hdmi *hdmi, struct device_node *np, in mtk_hdmi_get_all_clk() argument
208 hdmi->clk[i] = of_clk_get_by_name(np, clock_names[i]); in mtk_hdmi_get_all_clk()
210 if (IS_ERR(hdmi->clk[i])) in mtk_hdmi_get_all_clk()
211 return PTR_ERR(hdmi->clk[i]); in mtk_hdmi_get_all_clk()
229 struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); in mtk_hdmi_bridge_mode_set() local
231 dev_dbg(hdmi->dev, "cur info: name:%s, hdisplay:%d\n", in mtk_hdmi_bridge_mode_set()
233 dev_dbg(hdmi->dev, "hsync_start:%d,hsync_end:%d, htotal:%d", in mtk_hdmi_bridge_mode_set()
236 dev_dbg(hdmi->dev, "hskew:%d, vdisplay:%d\n", in mtk_hdmi_bridge_mode_set()
238 dev_dbg(hdmi->dev, "vsync_start:%d, vsync_end:%d, vtotal:%d", in mtk_hdmi_bridge_mode_set()
241 dev_dbg(hdmi->dev, "vscan:%d, flag:%d\n", in mtk_hdmi_bridge_mode_set()
244 drm_mode_copy(&hdmi->mode, adjusted_mode); in mtk_hdmi_bridge_mode_set()
255 static int mtk_hdmi_get_cec_dev(struct mtk_hdmi *hdmi, struct device *dev, struct device_node *np) in mtk_hdmi_get_cec_dev() argument
261 /* The CEC module handles HDMI hotplug detection */ in mtk_hdmi_get_cec_dev()
268 dev_err(hdmi->dev, "Waiting for CEC device %pOF\n", cec_np); in mtk_hdmi_get_cec_dev()
279 * The mediatek,syscon-hdmi property contains a phandle link to the in mtk_hdmi_get_cec_dev()
283 hdmi->sys_regmap = syscon_regmap_lookup_by_phandle_args(np, "mediatek,syscon-hdmi", in mtk_hdmi_get_cec_dev()
284 1, &hdmi->sys_offset); in mtk_hdmi_get_cec_dev()
285 if (IS_ERR(hdmi->sys_regmap)) in mtk_hdmi_get_cec_dev()
286 return dev_err_probe(dev, PTR_ERR(hdmi->sys_regmap), in mtk_hdmi_get_cec_dev()
289 hdmi->cec_dev = &cec_pdev->dev; in mtk_hdmi_get_cec_dev()
293 static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, struct platform_device *pdev, in mtk_hdmi_dt_parse_pdata() argument
301 ret = mtk_hdmi_get_all_clk(hdmi, np, clk_names, num_clocks); in mtk_hdmi_dt_parse_pdata()
305 hdmi->irq = platform_get_irq(pdev, 0); in mtk_hdmi_dt_parse_pdata()
306 if (!hdmi->irq) in mtk_hdmi_dt_parse_pdata()
307 return hdmi->irq; in mtk_hdmi_dt_parse_pdata()
309 hdmi->regs = device_node_to_regmap(dev->of_node); in mtk_hdmi_dt_parse_pdata()
310 if (IS_ERR(hdmi->regs)) in mtk_hdmi_dt_parse_pdata()
311 return PTR_ERR(hdmi->regs); in mtk_hdmi_dt_parse_pdata()
317 if (!of_device_is_compatible(remote, "hdmi-connector")) { in mtk_hdmi_dt_parse_pdata()
318 hdmi->next_bridge = of_drm_find_bridge(remote); in mtk_hdmi_dt_parse_pdata()
319 if (!hdmi->next_bridge) { in mtk_hdmi_dt_parse_pdata()
331 hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np); in mtk_hdmi_dt_parse_pdata()
333 if (!hdmi->ddc_adpt) in mtk_hdmi_dt_parse_pdata()
336 ret = devm_add_action_or_reset(dev, mtk_hdmi_put_device, &hdmi->ddc_adpt->dev); in mtk_hdmi_dt_parse_pdata()
340 ret = mtk_hdmi_get_cec_dev(hdmi, dev, np); in mtk_hdmi_dt_parse_pdata()
356 struct mtk_hdmi *hdmi = dev_get_drvdata(dev); in mtk_hdmi_register_audio_driver() local
357 struct hdmi_audio_param *aud_param = &hdmi->aud_param; in mtk_hdmi_register_audio_driver()
359 .ops = hdmi->conf->ver_conf->codec_ops, in mtk_hdmi_register_audio_driver()
362 .data = hdmi, in mtk_hdmi_register_audio_driver()
374 hdmi->audio_pdev = platform_device_register_data(dev, in mtk_hdmi_register_audio_driver()
379 if (IS_ERR(hdmi->audio_pdev)) in mtk_hdmi_register_audio_driver()
380 return PTR_ERR(hdmi->audio_pdev); in mtk_hdmi_register_audio_driver()
383 hdmi->audio_pdev); in mtk_hdmi_register_audio_driver()
395 struct mtk_hdmi *hdmi; in mtk_hdmi_common_probe() local
404 hdmi = devm_drm_bridge_alloc(dev, struct mtk_hdmi, bridge, in mtk_hdmi_common_probe()
406 if (IS_ERR(hdmi)) in mtk_hdmi_common_probe()
407 return hdmi; in mtk_hdmi_common_probe()
409 hdmi->dev = dev; in mtk_hdmi_common_probe()
410 hdmi->conf = hdmi_conf; in mtk_hdmi_common_probe()
412 hdmi->clk = devm_kcalloc(dev, ver_conf->num_clocks, sizeof(*hdmi->clk), GFP_KERNEL); in mtk_hdmi_common_probe()
413 if (!hdmi->clk) in mtk_hdmi_common_probe()
416 ret = mtk_hdmi_dt_parse_pdata(hdmi, pdev, ver_conf->mtk_hdmi_clock_names, in mtk_hdmi_common_probe()
421 hdmi->phy = devm_phy_get(dev, "hdmi"); in mtk_hdmi_common_probe()
422 if (IS_ERR(hdmi->phy)) in mtk_hdmi_common_probe()
423 return dev_err_cast_probe(dev, hdmi->phy, "Failed to get HDMI PHY\n"); in mtk_hdmi_common_probe()
425 mutex_init(&hdmi->update_plugged_status_lock); in mtk_hdmi_common_probe()
426 platform_set_drvdata(pdev, hdmi); in mtk_hdmi_common_probe()
430 return dev_err_ptr_probe(dev, ret, "Cannot register HDMI Audio driver\n"); in mtk_hdmi_common_probe()
432 hdmi->bridge.of_node = pdev->dev.of_node; in mtk_hdmi_common_probe()
433 hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID in mtk_hdmi_common_probe()
438 hdmi->bridge.ops |= DRM_BRIDGE_OP_HDMI; in mtk_hdmi_common_probe()
440 hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA; in mtk_hdmi_common_probe()
441 hdmi->bridge.ddc = hdmi->ddc_adpt; in mtk_hdmi_common_probe()
442 hdmi->bridge.vendor = "MediaTek"; in mtk_hdmi_common_probe()
443 hdmi->bridge.product = "On-Chip HDMI"; in mtk_hdmi_common_probe()
444 hdmi->bridge.interlace_allowed = ver_conf->interlace_allowed; in mtk_hdmi_common_probe()
446 ret = devm_drm_bridge_add(dev, &hdmi->bridge); in mtk_hdmi_common_probe()
450 return hdmi; in mtk_hdmi_common_probe()
455 MODULE_DESCRIPTION("MediaTek HDMI Common Library");