summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm2/ecore_drm2_outputs.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2017-08-03 13:42:32 -0500
committerDerek Foreman <derekf@osg.samsung.com>2017-08-09 14:56:58 -0500
commit9b9d704292258f1ee1412cc3f2f2ae638bb5237c (patch)
tree26ddaf718aab2fb9cd0690c732edd851e949ebf1 /src/lib/ecore_drm2/ecore_drm2_outputs.c
parent2f9cb33f0b41fb82ba481ca4f9792f59e0995def (diff)
ecore_drm2: Remove connector bitfield
This is unreliable - there's no reason to expect these connector ids will be low enough to sensibly store in a bit field.
Diffstat (limited to 'src/lib/ecore_drm2/ecore_drm2_outputs.c')
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_outputs.c79
1 files changed, 43 insertions, 36 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c b/src/lib/ecore_drm2/ecore_drm2_outputs.c
index c5f0d6b995..7c460c0c7f 100644
--- a/src/lib/ecore_drm2/ecore_drm2_outputs.c
+++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c
@@ -771,7 +771,6 @@ _output_create(Ecore_Drm2_Device *dev, const drmModeRes *res, const drmModeConne
771 output->enabled = EINA_FALSE; 771 output->enabled = EINA_FALSE;
772 } 772 }
773 773
774 dev->alloc.conn |= (1 << output->conn_id);
775 dev->outputs = eina_list_append(dev->outputs, output); 774 dev->outputs = eina_list_append(dev->outputs, output);
776 775
777 _output_debug(output, conn); 776 _output_debug(output, conn);
@@ -784,17 +783,38 @@ _output_create(Ecore_Drm2_Device *dev, const drmModeRes *res, const drmModeConne
784 return EINA_TRUE; 783 return EINA_TRUE;
785} 784}
786 785
786static Ecore_Drm2_Output *
787_output_find_by_con(Ecore_Drm2_Device *dev, uint32_t id)
788{
789 Ecore_Drm2_Output *output;
790 Eina_List *l;
791
792 EINA_LIST_FOREACH(dev->outputs, l, output)
793 if (output->conn_id == id) return output;
794
795 return NULL;
796}
797
787static void 798static void
788_outputs_update(Ecore_Drm2_Device *dev) 799_outputs_update(Ecore_Drm2_Device *dev)
789{ 800{
801 Ecore_Drm2_Output *output;
802 Eina_List *l, *ll;
790 drmModeRes *res; 803 drmModeRes *res;
791 drmModeConnector *conn; 804 drmModeConnector *conn;
792 uint32_t connected = 0, disconnected = 0; 805 uint32_t *connected;
793 int i = 0, x = 0, y = 0; 806 int i = 0, x = 0, y = 0;
794 807
795 res = sym_drmModeGetResources(dev->fd); 808 res = sym_drmModeGetResources(dev->fd);
796 if (!res) return; 809 if (!res) return;
797 810
811 connected = calloc(res->count_connectors, sizeof(uint32_t));
812 if (!connected)
813 {
814 sym_drmModeFreeResources(res);
815 return;
816 }
817
798 for (i = 0; i < res->count_connectors; i++) 818 for (i = 0; i < res->count_connectors; i++)
799 { 819 {
800 conn = sym_drmModeGetConnector(dev->fd, res->connectors[i]); 820 conn = sym_drmModeGetConnector(dev->fd, res->connectors[i]);
@@ -802,9 +822,8 @@ _outputs_update(Ecore_Drm2_Device *dev)
802 822
803 if (conn->connection != DRM_MODE_CONNECTED) goto next; 823 if (conn->connection != DRM_MODE_CONNECTED) goto next;
804 824
805 connected |= (1 << res->connectors[i]); 825 connected[i] = res->connectors[i];
806 826 if (!_output_find_by_con(dev, res->connectors[i]))
807 if (!(dev->alloc.conn & (1 << res->connectors[i])))
808 { 827 {
809 if (dev->outputs) 828 if (dev->outputs)
810 { 829 {
@@ -827,41 +846,31 @@ next:
827 846
828 sym_drmModeFreeResources(res); 847 sym_drmModeFreeResources(res);
829 848
830 disconnected = (dev->alloc.conn & ~connected); 849 EINA_LIST_FOREACH_SAFE(dev->outputs, l, ll, output)
831 if (disconnected)
832 { 850 {
833 Ecore_Drm2_Output *output; 851 Eina_Bool disconnected = EINA_TRUE;
834 Eina_List *l; 852
853 for (i = 0; i < res->count_connectors; i++)
854 if (connected[i] == output->conn_id)
855 {
856 disconnected = EINA_FALSE;
857 break;
858 }
835 859
836 EINA_LIST_FOREACH(dev->outputs, l, output) 860 if (disconnected)
837 { 861 {
838 if (disconnected & (1 << output->conn_id)) 862 output->connected = EINA_FALSE;
839 { 863 output->enabled = EINA_FALSE;
840 disconnected &= ~(1 << output->conn_id); 864 _output_event_send(output);
841 output->connected = EINA_FALSE;
842 output->enabled = EINA_FALSE;
843 _output_event_send(output);
844 }
845 } 865 }
846 } 866 else
847
848 connected = (dev->alloc.conn & connected);
849 if (connected)
850 {
851 Ecore_Drm2_Output *output;
852 Eina_List *l;
853
854 EINA_LIST_FOREACH(dev->outputs, l, output)
855 { 867 {
856 if (connected & (1 << output->conn_id)) 868 output->connected = EINA_TRUE;
857 { 869 output->enabled = EINA_TRUE;
858 connected &= ~(1 << output->conn_id); 870 _output_event_send(output);
859 output->connected = EINA_TRUE;
860 output->enabled = EINA_TRUE;
861 _output_event_send(output);
862 }
863 } 871 }
864 } 872 }
873 free(connected);
865} 874}
866 875
867static void 876static void
@@ -874,7 +883,7 @@ _cb_output_event(const char *device EINA_UNUSED, Eeze_Udev_Event event EINA_UNUS
874} 883}
875 884
876static void 885static void
877_output_destroy(Ecore_Drm2_Device *dev, Ecore_Drm2_Output *output) 886_output_destroy(Ecore_Drm2_Device *dev EINA_UNUSED, Ecore_Drm2_Output *output)
878{ 887{
879 Ecore_Drm2_Output_Mode *mode; 888 Ecore_Drm2_Output_Mode *mode;
880 Ecore_Drm2_Plane *plane; 889 Ecore_Drm2_Plane *plane;
@@ -905,8 +914,6 @@ _output_destroy(Ecore_Drm2_Device *dev, Ecore_Drm2_Output *output)
905 free(mode); 914 free(mode);
906 } 915 }
907 916
908 dev->alloc.conn &= ~(1 << output->conn_id);
909
910 eina_stringshare_del(output->backlight.path); 917 eina_stringshare_del(output->backlight.path);
911 eina_stringshare_del(output->name); 918 eina_stringshare_del(output->name);
912 eina_stringshare_del(output->make); 919 eina_stringshare_del(output->make);