Lines Matching +full:audio +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0
26 #include <sound/hdmi-codec.h>
96 #define HDMI_IFRAME_CFG_DI_N(x, n) ((x) << ((n-1)*4)) /* n from 1 to 6 */
179 return readl(hdmi->regs + offset); in hdmi_read()
184 writel(val, hdmi->regs + offset); in hdmi_write()
198 if (hdmi->irq_status & HDMI_INT_HOT_PLUG) { in hdmi_irq_thread()
199 hdmi->hpd = readl(hdmi->regs + HDMI_STA) & HDMI_STA_HOT_PLUG; in hdmi_irq_thread()
200 if (hdmi->drm_dev) in hdmi_irq_thread()
201 drm_helper_hpd_irq_event(hdmi->drm_dev); in hdmi_irq_thread()
207 if (hdmi->irq_status & (HDMI_INT_SW_RST | HDMI_INT_DLL_LCK)) { in hdmi_irq_thread()
208 hdmi->event_received = true; in hdmi_irq_thread()
209 wake_up_interruptible(&hdmi->wait_event); in hdmi_irq_thread()
212 /* Audio FIFO underrun IRQ */ in hdmi_irq_thread()
213 if (hdmi->irq_status & HDMI_INT_AUDIO_FIFO_XRUN) in hdmi_irq_thread()
214 DRM_INFO("Warning: audio FIFO underrun occurs!\n"); in hdmi_irq_thread()
230 hdmi->irq_status = hdmi_read(hdmi, HDMI_INT_STA); in hdmi_irq()
233 hdmi_write(hdmi, hdmi->irq_status, HDMI_INT_CLR); in hdmi_irq()
251 xmin = sti_vtg_get_pixel_number(hdmi->mode, 1); in hdmi_active_area()
252 xmax = sti_vtg_get_pixel_number(hdmi->mode, hdmi->mode.hdisplay); in hdmi_active_area()
253 ymin = sti_vtg_get_line_number(hdmi->mode, 0); in hdmi_active_area()
254 ymax = sti_vtg_get_line_number(hdmi->mode, hdmi->mode.vdisplay - 1); in hdmi_active_area()
269 struct drm_connector *connector = hdmi->drm_connector; in hdmi_config()
279 if (connector->display_info.is_hdmi) in hdmi_config()
283 if (hdmi->mode.flags & DRM_MODE_FLAG_NHSYNC) { in hdmi_config()
289 if (hdmi->mode.flags & DRM_MODE_FLAG_NVSYNC) { in hdmi_config()
294 /* Enable HDMI */ in hdmi_config()
352 for (i = size; i > 0; i--) in hdmi_infoframe_subpack()
353 value = (value << 8) | ptr[i - 1]; in hdmi_infoframe_subpack()
405 writel(val, hdmi->regs + head_offset); in hdmi_infoframe_write_infopack()
412 size = size - HDMI_INFOFRAME_HEADER_SIZE + 1; in hdmi_infoframe_write_infopack()
416 num = min_t(size_t, size - i, sizeof(u32)); in hdmi_infoframe_write_infopack()
419 writel(val, hdmi->regs + pack_offset + i); in hdmi_infoframe_write_infopack()
422 /* Enable transmission slot for updated infoframe */ in hdmi_infoframe_write_infopack()
441 struct drm_display_mode *mode = &hdmi->mode; in hdmi_avi_infoframe_config()
449 hdmi->drm_connector, mode); in hdmi_avi_infoframe_config()
456 infoframe.colorspace = hdmi->colorspace; in hdmi_avi_infoframe_config()
472 * Prepare and configure the AUDIO infoframe
474 * AUDIO infoframe are transmitted once per frame and
475 * contains information about HDMI transmission mode such as audio codec,
484 struct hdmi_audio_params *audio = &hdmi->audio; in hdmi_audio_infoframe_config() local
485 u8 buffer[HDMI_INFOFRAME_SIZE(AUDIO)]; in hdmi_audio_infoframe_config()
489 audio->enabled ? "enable" : "disable"); in hdmi_audio_infoframe_config()
490 if (audio->enabled) { in hdmi_audio_infoframe_config()
491 /* set audio parameters stored*/ in hdmi_audio_infoframe_config()
492 ret = hdmi_audio_infoframe_pack(&audio->cea, buffer, in hdmi_audio_infoframe_config()
495 DRM_ERROR("failed to pack audio infoframe: %d\n", ret); in hdmi_audio_infoframe_config()
500 /*disable audio info frame transmission */ in hdmi_audio_infoframe_config()
523 struct drm_display_mode *mode = &hdmi->mode; in hdmi_vendor_infoframe_config()
531 hdmi->drm_connector, in hdmi_vendor_infoframe_config()
568 /* Enable hdmi_audio clock only during hdmi reset */ in hdmi_swreset()
569 if (clk_prepare_enable(hdmi->clk_audio)) in hdmi_swreset()
570 DRM_INFO("Failed to prepare/enable hdmi_audio clk\n"); in hdmi_swreset()
573 hdmi->event_received = false; in hdmi_swreset()
580 wait_event_interruptible_timeout(hdmi->wait_event, in hdmi_swreset()
581 hdmi->event_received, in hdmi_swreset()
597 clk_disable_unprepare(hdmi->clk_audio); in hdmi_swreset()
600 #define DBGFS_PRINT_STR(str1, str2) seq_printf(s, "%-24s %s\n", str1, str2)
601 #define DBGFS_PRINT_INT(str1, int2) seq_printf(s, "%-24s %d\n", str1, int2)
602 #define DBGFS_DUMP(str, reg) seq_printf(s, "%s %-25s 0x%08X", str, #reg, \
615 DBGFS_PRINT_STR("HDCP:", tmp ? "enable" : "disable"); in hdmi_dbg_cfg()
618 DBGFS_PRINT_STR("HDCP mode:", tmp ? "ESS enable" : "OESS enable"); in hdmi_dbg_cfg()
627 DBGFS_PRINT_STR("YUV422 format:", tmp ? "enable" : "disable"); in hdmi_dbg_cfg()
672 struct drm_info_node *node = s->private; in hdmi_dbg_show()
673 struct sti_hdmi *hdmi = (struct sti_hdmi *)node->info_ent->data; in hdmi_dbg_show()
675 seq_printf(s, "HDMI: (vaddr = 0x%p)", hdmi->regs); in hdmi_dbg_show()
710 seq_printf(s, "\n\n AUDIO Infoframe (Data Island slot N=%d):", in hdmi_dbg_show()
747 minor->debugfs_root, minor); in hdmi_debugfs_init()
752 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_disable()
756 if (!hdmi->enabled) in sti_hdmi_disable()
768 hdmi->phy_ops->stop(hdmi); in sti_hdmi_disable()
781 clk_disable_unprepare(hdmi->clk_phy); in sti_hdmi_disable()
782 clk_disable_unprepare(hdmi->clk_tmds); in sti_hdmi_disable()
783 clk_disable_unprepare(hdmi->clk_pix); in sti_hdmi_disable()
785 hdmi->enabled = false; in sti_hdmi_disable()
787 cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID); in sti_hdmi_disable()
791 * sti_hdmi_audio_get_non_coherent_n() - get N parameter for non-coherent
792 * clocks. None-coherent clocks means that audio and TMDS clocks have not the
796 * @audio_fs: audio frame clock frequency in Hz
829 /* Not pre-defined, recommended value: 128 * fs / 1000 */ in sti_hdmi_audio_get_non_coherent_n()
839 struct hdmi_audio_params *params = &hdmi->audio; in hdmi_audio_configure()
840 struct hdmi_audio_infoframe *info = &params->cea; in hdmi_audio_configure()
844 if (!hdmi->enabled) in hdmi_audio_configure()
848 n = sti_hdmi_audio_get_non_coherent_n(params->sample_rate); in hdmi_audio_configure()
850 DRM_DEBUG_DRIVER("Audio rate = %d Hz, TMDS clock = %d Hz, n = %d\n", in hdmi_audio_configure()
851 params->sample_rate, hdmi->mode.clock * 1000, n); in hdmi_audio_configure()
858 switch (info->channels) { in hdmi_audio_configure()
873 info->channels); in hdmi_audio_configure()
874 return -EINVAL; in hdmi_audio_configure()
884 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_pre_enable()
888 if (hdmi->enabled) in sti_hdmi_pre_enable()
891 /* Prepare/enable clocks */ in sti_hdmi_pre_enable()
892 if (clk_prepare_enable(hdmi->clk_pix)) in sti_hdmi_pre_enable()
893 DRM_ERROR("Failed to prepare/enable hdmi_pix clk\n"); in sti_hdmi_pre_enable()
894 if (clk_prepare_enable(hdmi->clk_tmds)) in sti_hdmi_pre_enable()
895 DRM_ERROR("Failed to prepare/enable hdmi_tmds clk\n"); in sti_hdmi_pre_enable()
896 if (clk_prepare_enable(hdmi->clk_phy)) in sti_hdmi_pre_enable()
897 DRM_ERROR("Failed to prepare/enable hdmi_rejection_pll clk\n"); in sti_hdmi_pre_enable()
899 hdmi->enabled = true; in sti_hdmi_pre_enable()
902 if (!hdmi->phy_ops->start(hdmi)) { in sti_hdmi_pre_enable()
910 /* Enable working interrupts */ in sti_hdmi_pre_enable()
920 if (hdmi->audio.enabled) { in sti_hdmi_pre_enable()
922 DRM_ERROR("Unable to configure audio\n"); in sti_hdmi_pre_enable()
939 struct sti_hdmi *hdmi = bridge->driver_private; in sti_hdmi_set_mode()
945 drm_mode_copy(&hdmi->mode, mode); in sti_hdmi_set_mode()
948 ret = clk_set_rate(hdmi->clk_pix, mode->clock * 1000); in sti_hdmi_set_mode()
951 mode->clock * 1000); in sti_hdmi_set_mode()
954 ret = clk_set_rate(hdmi->clk_phy, mode->clock * 1000); in sti_hdmi_set_mode()
957 mode->clock * 1000); in sti_hdmi_set_mode()
969 .enable = sti_hdmi_bridge_nope,
977 const struct drm_display_info *info = &connector->display_info; in sti_hdmi_connector_get_modes()
980 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_get_modes()
990 cec_notifier_set_phys_addr(hdmi->notifier, in sti_hdmi_connector_get_modes()
991 connector->display_info.source_physical_address); in sti_hdmi_connector_get_modes()
999 info->is_hdmi ? "hdmi monitor" : "dvi monitor", in sti_hdmi_connector_get_modes()
1000 info->width_mm / 10, info->height_mm / 10); in sti_hdmi_connector_get_modes()
1016 int target = mode->clock * 1000; in sti_hdmi_connector_mode_valid()
1017 int target_min = target - CLK_TOLERANCE_HZ; in sti_hdmi_connector_mode_valid()
1022 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_mode_valid()
1025 result = clk_round_rate(hdmi->clk_pix, target); in sti_hdmi_connector_mode_valid()
1050 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_detect()
1054 if (hdmi->hpd) { in sti_hdmi_connector_detect()
1060 cec_notifier_set_phys_addr(hdmi->notifier, CEC_PHYS_ADDR_INVALID); in sti_hdmi_connector_detect()
1069 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_init_property()
1073 hdmi->colorspace = DEFAULT_COLORSPACE_MODE; in sti_hdmi_connector_init_property()
1081 hdmi_connector->colorspace_property = prop; in sti_hdmi_connector_init_property()
1082 drm_object_attach_property(&connector->base, prop, hdmi->colorspace); in sti_hdmi_connector_init_property()
1093 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_set_property()
1095 if (property == hdmi_connector->colorspace_property) { in sti_hdmi_connector_set_property()
1096 hdmi->colorspace = val; in sti_hdmi_connector_set_property()
1101 return -EINVAL; in sti_hdmi_connector_set_property()
1112 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_connector_get_property()
1114 if (property == hdmi_connector->colorspace_property) { in sti_hdmi_connector_get_property()
1115 *val = hdmi->colorspace; in sti_hdmi_connector_get_property()
1120 return -EINVAL; in sti_hdmi_connector_get_property()
1127 struct sti_hdmi *hdmi = hdmi_connector->hdmi; in sti_hdmi_late_register()
1129 hdmi_debugfs_init(hdmi, hdmi->drm_dev->primary); in sti_hdmi_late_register()
1150 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { in sti_hdmi_find_encoder()
1151 if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) in sti_hdmi_find_encoder()
1165 /* disable audio */ in hdmi_audio_shutdown()
1170 hdmi->audio.enabled = false; in hdmi_audio_shutdown()
1184 if ((daifmt->fmt != HDMI_I2S) || daifmt->bit_clk_inv || in hdmi_audio_hw_params()
1185 daifmt->frame_clk_inv || daifmt->bit_clk_provider || in hdmi_audio_hw_params()
1186 daifmt->frame_clk_provider) { in hdmi_audio_hw_params()
1188 daifmt->bit_clk_inv, daifmt->frame_clk_inv, in hdmi_audio_hw_params()
1189 daifmt->bit_clk_provider, in hdmi_audio_hw_params()
1190 daifmt->frame_clk_provider); in hdmi_audio_hw_params()
1191 return -EINVAL; in hdmi_audio_hw_params()
1194 hdmi->audio.sample_width = params->sample_width; in hdmi_audio_hw_params()
1195 hdmi->audio.sample_rate = params->sample_rate; in hdmi_audio_hw_params()
1196 hdmi->audio.cea = params->cea; in hdmi_audio_hw_params()
1198 hdmi->audio.enabled = true; in hdmi_audio_hw_params()
1208 bool enable, int direction) in hdmi_audio_mute() argument
1212 DRM_DEBUG_DRIVER("%s\n", enable ? "enable" : "disable"); in hdmi_audio_mute()
1214 if (enable) in hdmi_audio_mute()
1225 struct drm_connector *connector = hdmi->drm_connector; in hdmi_audio_get_eld()
1228 memcpy(buf, connector->eld, min(sizeof(connector->eld), len)); in hdmi_audio_get_eld()
1252 hdmi->audio.enabled = false; in sti_hdmi_register_audio_driver()
1254 hdmi->audio_pdev = platform_device_register_data( in sti_hdmi_register_audio_driver()
1258 if (IS_ERR(hdmi->audio_pdev)) in sti_hdmi_register_audio_driver()
1259 return PTR_ERR(hdmi->audio_pdev); in sti_hdmi_register_audio_driver()
1278 hdmi->drm_dev = drm_dev; in sti_hdmi_bind()
1282 return -EINVAL; in sti_hdmi_bind()
1286 return -EINVAL; in sti_hdmi_bind()
1288 connector->hdmi = hdmi; in sti_hdmi_bind()
1292 return -EINVAL; in sti_hdmi_bind()
1294 bridge->driver_private = hdmi; in sti_hdmi_bind()
1295 bridge->funcs = &sti_hdmi_bridge_funcs; in sti_hdmi_bind()
1298 connector->encoder = encoder; in sti_hdmi_bind()
1302 drm_connector->polled = DRM_CONNECTOR_POLL_HPD; in sti_hdmi_bind()
1307 hdmi->ddc_adapt); in sti_hdmi_bind()
1314 hdmi->drm_connector = drm_connector; in sti_hdmi_bind()
1324 DRM_ERROR("Failed to attach an audio codec\n"); in sti_hdmi_bind()
1328 /* Initialize audio infoframe */ in sti_hdmi_bind()
1329 err = hdmi_audio_infoframe_init(&hdmi->audio.cea); in sti_hdmi_bind()
1331 DRM_ERROR("Failed to init audio infoframe\n"); in sti_hdmi_bind()
1336 hdmi->notifier = cec_notifier_conn_register(&hdmi->dev, NULL, in sti_hdmi_bind()
1338 if (!hdmi->notifier) { in sti_hdmi_bind()
1339 hdmi->drm_connector = NULL; in sti_hdmi_bind()
1340 return -ENOMEM; in sti_hdmi_bind()
1343 /* Enable default interrupts */ in sti_hdmi_bind()
1349 hdmi->drm_connector = NULL; in sti_hdmi_bind()
1350 return -EINVAL; in sti_hdmi_bind()
1358 cec_notifier_conn_unregister(hdmi->notifier); in sti_hdmi_unbind()
1368 .compatible = "st,stih407-hdmi",
1378 struct device *dev = &pdev->dev; in sti_hdmi_probe()
1380 struct device_node *np = dev->of_node; in sti_hdmi_probe()
1389 return -ENOMEM; in sti_hdmi_probe()
1391 ddc = of_parse_phandle(pdev->dev.of_node, "ddc", 0); in sti_hdmi_probe()
1393 hdmi->ddc_adapt = of_get_i2c_adapter_by_node(ddc); in sti_hdmi_probe()
1395 if (!hdmi->ddc_adapt) in sti_hdmi_probe()
1396 return -EPROBE_DEFER; in sti_hdmi_probe()
1399 hdmi->dev = pdev->dev; in sti_hdmi_probe()
1402 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi-reg"); in sti_hdmi_probe()
1405 ret = -ENOMEM; in sti_hdmi_probe()
1408 hdmi->regs = devm_ioremap(dev, res->start, resource_size(res)); in sti_hdmi_probe()
1409 if (!hdmi->regs) { in sti_hdmi_probe()
1410 ret = -ENOMEM; in sti_hdmi_probe()
1414 hdmi->phy_ops = (struct hdmi_phy_ops *) in sti_hdmi_probe()
1415 of_match_node(hdmi_of_match, np)->data; in sti_hdmi_probe()
1418 hdmi->clk_pix = devm_clk_get(dev, "pix"); in sti_hdmi_probe()
1419 if (IS_ERR(hdmi->clk_pix)) { in sti_hdmi_probe()
1421 ret = PTR_ERR(hdmi->clk_pix); in sti_hdmi_probe()
1425 hdmi->clk_tmds = devm_clk_get(dev, "tmds"); in sti_hdmi_probe()
1426 if (IS_ERR(hdmi->clk_tmds)) { in sti_hdmi_probe()
1428 ret = PTR_ERR(hdmi->clk_tmds); in sti_hdmi_probe()
1432 hdmi->clk_phy = devm_clk_get(dev, "phy"); in sti_hdmi_probe()
1433 if (IS_ERR(hdmi->clk_phy)) { in sti_hdmi_probe()
1435 ret = PTR_ERR(hdmi->clk_phy); in sti_hdmi_probe()
1439 hdmi->clk_audio = devm_clk_get(dev, "audio"); in sti_hdmi_probe()
1440 if (IS_ERR(hdmi->clk_audio)) { in sti_hdmi_probe()
1442 ret = PTR_ERR(hdmi->clk_audio); in sti_hdmi_probe()
1446 hdmi->hpd = readl(hdmi->regs + HDMI_STA) & HDMI_STA_HOT_PLUG; in sti_hdmi_probe()
1448 init_waitqueue_head(&hdmi->wait_event); in sti_hdmi_probe()
1450 hdmi->irq = platform_get_irq_byname(pdev, "irq"); in sti_hdmi_probe()
1451 if (hdmi->irq < 0) { in sti_hdmi_probe()
1453 ret = hdmi->irq; in sti_hdmi_probe()
1457 ret = devm_request_threaded_irq(dev, hdmi->irq, hdmi_irq, in sti_hdmi_probe()
1464 hdmi->reset = devm_reset_control_get(dev, "hdmi"); in sti_hdmi_probe()
1466 if (!IS_ERR(hdmi->reset)) in sti_hdmi_probe()
1467 reset_control_deassert(hdmi->reset); in sti_hdmi_probe()
1471 return component_add(&pdev->dev, &sti_hdmi_ops); in sti_hdmi_probe()
1474 i2c_put_adapter(hdmi->ddc_adapt); in sti_hdmi_probe()
1481 struct sti_hdmi *hdmi = dev_get_drvdata(&pdev->dev); in sti_hdmi_remove()
1483 i2c_put_adapter(hdmi->ddc_adapt); in sti_hdmi_remove()
1484 if (hdmi->audio_pdev) in sti_hdmi_remove()
1485 platform_device_unregister(hdmi->audio_pdev); in sti_hdmi_remove()
1486 component_del(&pdev->dev, &sti_hdmi_ops); in sti_hdmi_remove()
1491 .name = "sti-hdmi",