summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Michael <cp.michael@samsung.com>2019-02-06 08:19:52 -0500
committerChristopher Michael <cp.michael@samsung.com>2019-12-03 11:17:28 -0500
commitf18ef50c1d93518dac0938aa80a8ab53ae57bbce (patch)
tree523559b5f7ae281435d46209309b5a6a1da1e673
parent7d40e03ca701d8f4476c62b7aa42557786eb96b5 (diff)
ecore-drm2: Add API function to clone an output
This patch adds an API function which we can call from inside Enlightenment in order to clone a given output. @feature
-rw-r--r--src/lib/ecore_drm2/Ecore_Drm2.h13
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_outputs.c59
2 files changed, 69 insertions, 3 deletions
diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 5c43258177..b6e8973ef1 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -883,6 +883,19 @@ EAPI void ecore_drm2_output_relative_to_set(Ecore_Drm2_Output *output, const cha
883EAPI const char *ecore_drm2_output_relative_to_get(Ecore_Drm2_Output *output); 883EAPI const char *ecore_drm2_output_relative_to_get(Ecore_Drm2_Output *output);
884 884
885/** 885/**
886 * Set if a given output is cloned
887 *
888 * @param output The output to set as cloned
889 * @param clone The output of which to clone, or NULL to unclone
890 *
891 * @return EINA_TRUE on success, EINA_FALSE otherwise
892 *
893 * @ingroup Ecore_Drm2_Output_Group
894 * @since 1.22
895 */
896EAPI Eina_Bool ecore_drm2_output_clone_set(Ecore_Drm2_Output *output, Ecore_Drm2_Output *clone);
897
898/**
886 * @defgroup Ecore_Drm2_Fb_Group Drm framebuffer functions 899 * @defgroup Ecore_Drm2_Fb_Group Drm framebuffer functions
887 * 900 *
888 * Functions that deal with setup of framebuffers 901 * Functions that deal with setup of framebuffers
diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c b/src/lib/ecore_drm2/ecore_drm2_outputs.c
index 6fe3eb5770..7bf5bc0c71 100644
--- a/src/lib/ecore_drm2/ecore_drm2_outputs.c
+++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c
@@ -250,7 +250,7 @@ _output_edid_find(Ecore_Drm2_Output *output, const drmModeConnector *conn)
250} 250}
251 251
252static int 252static int
253_output_crtc_find(const drmModeRes *res, const drmModeConnector *conn, Ecore_Drm2_Device *dev) 253_output_crtc_find(const drmModeRes *res, const drmModeConnector *conn, int fd)
254{ 254{
255 drmModeEncoder *enc; 255 drmModeEncoder *enc;
256 uint32_t crtc; 256 uint32_t crtc;
@@ -267,7 +267,7 @@ _output_crtc_find(const drmModeRes *res, const drmModeConnector *conn, Ecore_Drm
267 267
268 for (j = 0; j < conn->count_encoders; j++) 268 for (j = 0; j < conn->count_encoders; j++)
269 { 269 {
270 enc = sym_drmModeGetEncoder(dev->fd, conn->encoders[j]); 270 enc = sym_drmModeGetEncoder(fd, conn->encoders[j]);
271 if (!enc) continue; 271 if (!enc) continue;
272 272
273 crtc = enc->crtc_id; 273 crtc = enc->crtc_id;
@@ -678,7 +678,7 @@ _output_create(Ecore_Drm2_Device *dev, const drmModeRes *res, const drmModeConne
678 678
679 if (w) *w = 0; 679 if (w) *w = 0;
680 680
681 i = _output_crtc_find(res, conn, dev); 681 i = _output_crtc_find(res, conn, dev->fd);
682 if (i < 0) return EINA_FALSE; 682 if (i < 0) return EINA_FALSE;
683 683
684 output = calloc(1, sizeof(Ecore_Drm2_Output)); 684 output = calloc(1, sizeof(Ecore_Drm2_Output));
@@ -1764,3 +1764,56 @@ ecore_drm2_output_background_color_set(Ecore_Drm2_Output *output, uint64_t r, ui
1764 1764
1765 return EINA_FALSE; 1765 return EINA_FALSE;
1766} 1766}
1767
1768EAPI Eina_Bool
1769ecore_drm2_output_clone_set(Ecore_Drm2_Output *output, Ecore_Drm2_Output *clone)
1770{
1771 Eina_Bool ret = EINA_FALSE;
1772
1773 EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE);
1774
1775 if (clone)
1776 {
1777 if (ecore_drm2_output_possible_crtc_get(output, clone->crtc_id))
1778 {
1779 output->crtc_id = clone->crtc_id;
1780 output->cloned = EINA_TRUE;
1781 ret = EINA_TRUE;
1782 }
1783 }
1784 else if (output->cloned)
1785 {
1786 drmModeRes *res;
1787 drmModeConnector *conn;
1788 int j = 0, i = 0;
1789
1790 res = sym_drmModeGetResources(output->fd);
1791 if (!res) return EINA_FALSE;
1792
1793 for (j = 0; j < res->count_connectors; j++)
1794 {
1795 conn = sym_drmModeGetConnector(output->fd, res->connectors[j]);
1796 if (!conn) continue;
1797
1798 if (conn->connector_id == output->conn_id)
1799 {
1800 i = _output_crtc_find(res, conn, output->fd);
1801 if (i < 0)
1802 ret = EINA_FALSE;
1803 else
1804 {
1805 output->crtc_id = res->crtcs[i];
1806 output->cloned = EINA_FALSE;
1807 ret = EINA_TRUE;
1808 }
1809 }
1810
1811 sym_drmModeFreeConnector(conn);
1812 if (ret) break;
1813 }
1814
1815 sym_drmModeFreeResources(res);
1816 }
1817
1818 return ret;
1819}