Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/dsi: add helpers for DSI compression mode and PPS packets

Add helper functions for sending the DSI compression mode and picture
parameter set data type packets. For the time being, limit the support
to using VESA DSC 1.1 and the default PPS. This may need updating if the
need arises for proprietary compression or non-default PPS, however keep
it simple for starters.

v2: Add missing EXPORT_SYMBOL

Cc: Vandita Kulkarni <vandita.kulkarni@intel.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191028150047.22048-5-jani.nikula@intel.com

+55
+51
drivers/gpu/drm/drm_mipi_dsi.c
··· 33 33 #include <linux/pm_runtime.h> 34 34 #include <linux/slab.h> 35 35 36 + #include <drm/drm_dsc.h> 36 37 #include <video/mipi_display.h> 37 38 38 39 /** ··· 548 547 return (ret < 0) ? ret : 0; 549 548 } 550 549 EXPORT_SYMBOL(mipi_dsi_set_maximum_return_packet_size); 550 + 551 + /** 552 + * mipi_dsi_compression_mode() - enable/disable DSC on the peripheral 553 + * @dsi: DSI peripheral device 554 + * @enable: Whether to enable or disable the DSC 555 + * 556 + * Enable or disable Display Stream Compression on the peripheral using the 557 + * default Picture Parameter Set and VESA DSC 1.1 algorithm. 558 + * 559 + * Return: 0 on success or a negative error code on failure. 560 + */ 561 + ssize_t mipi_dsi_compression_mode(struct mipi_dsi_device *dsi, bool enable) 562 + { 563 + /* Note: Needs updating for non-default PPS or algorithm */ 564 + u8 tx[2] = { enable << 0, 0 }; 565 + struct mipi_dsi_msg msg = { 566 + .channel = dsi->channel, 567 + .type = MIPI_DSI_COMPRESSION_MODE, 568 + .tx_len = sizeof(tx), 569 + .tx_buf = tx, 570 + }; 571 + int ret = mipi_dsi_device_transfer(dsi, &msg); 572 + 573 + return (ret < 0) ? ret : 0; 574 + } 575 + EXPORT_SYMBOL(mipi_dsi_compression_mode); 576 + 577 + /** 578 + * mipi_dsi_picture_parameter_set() - transmit the DSC PPS to the peripheral 579 + * @dsi: DSI peripheral device 580 + * @pps: VESA DSC 1.1 Picture Parameter Set 581 + * 582 + * Transmit the VESA DSC 1.1 Picture Parameter Set to the peripheral. 583 + * 584 + * Return: 0 on success or a negative error code on failure. 585 + */ 586 + ssize_t mipi_dsi_picture_parameter_set(struct mipi_dsi_device *dsi, 587 + const struct drm_dsc_picture_parameter_set *pps) 588 + { 589 + struct mipi_dsi_msg msg = { 590 + .channel = dsi->channel, 591 + .type = MIPI_DSI_PICTURE_PARAMETER_SET, 592 + .tx_len = sizeof(*pps), 593 + .tx_buf = pps, 594 + }; 595 + int ret = mipi_dsi_device_transfer(dsi, &msg); 596 + 597 + return (ret < 0) ? ret : 0; 598 + } 599 + EXPORT_SYMBOL(mipi_dsi_picture_parameter_set); 551 600 552 601 /** 553 602 * mipi_dsi_generic_write() - transmit data using a generic write packet
+4
include/drm/drm_mipi_dsi.h
··· 13 13 14 14 struct mipi_dsi_host; 15 15 struct mipi_dsi_device; 16 + struct drm_dsc_picture_parameter_set; 16 17 17 18 /* request ACK from peripheral */ 18 19 #define MIPI_DSI_MSG_REQ_ACK BIT(0) ··· 229 228 int mipi_dsi_turn_on_peripheral(struct mipi_dsi_device *dsi); 230 229 int mipi_dsi_set_maximum_return_packet_size(struct mipi_dsi_device *dsi, 231 230 u16 value); 231 + ssize_t mipi_dsi_compression_mode(struct mipi_dsi_device *dsi, bool enable); 232 + ssize_t mipi_dsi_picture_parameter_set(struct mipi_dsi_device *dsi, 233 + const struct drm_dsc_picture_parameter_set *pps); 232 234 233 235 ssize_t mipi_dsi_generic_write(struct mipi_dsi_device *dsi, const void *payload, 234 236 size_t size);