Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Side by Side Diff: ch7036_monitor.c

Issue 6693053: Fix x width mapping when 720x480 mode is forced using -M1 (Closed) Base URL: ssh://gitrw.chromium.org:9222/chrontel.git@master
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <unistd.h> 7 #include <unistd.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <errno.h> 9 #include <errno.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 if (verbose) 715 if (verbose)
716 fprintf(stderr, "Found revision ID 0x%02x\n", 716 fprintf(stderr, "Found revision ID 0x%02x\n",
717 ch_read_reg(i2cdev, CH7036_REVID)); 717 ch_read_reg(i2cdev, CH7036_REVID));
718 718
719 if (gpiofile != NULL) { 719 if (gpiofile != NULL) {
720 gpiodev = open(gpiofile, O_RDONLY); 720 gpiodev = open(gpiofile, O_RDONLY);
721 if (gpiodev < 0) { 721 if (gpiodev < 0) {
722 fprintf(stderr, "Could not open %s: %s\n", gpiofile, strerror(errno)); 722 fprintf(stderr, "Could not open %s: %s\n", gpiofile, strerror(errno));
723 exit(1); 723 exit(1);
724 } 724 }
725 } 725 } else
726 gpiodev = 0;
726 727
727 dpy = XOpenDisplay(":0.0"); 728 dpy = XOpenDisplay(":0.0");
728 if (dpy == NULL) { 729 if (dpy == NULL) {
729 fprintf(stderr, "%s: Can't open display :0.0\n", argv[0]); 730 fprintf(stderr, "%s: Can't open display :0.0\n", argv[0]);
730 exit(1); 731 exit(1);
731 } 732 }
732 screen = DefaultScreen (dpy); 733 screen = DefaultScreen (dpy);
733 root = RootWindow (dpy, screen); 734 root = RootWindow (dpy, screen);
734 xmode = get_x_mode_info(dpy, root); 735 xmode = get_x_mode_info(dpy, root);
735 if (verbose) showmode(xmode); 736 if (verbose) showmode(xmode);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 if (verbose) { 874 if (verbose) {
874 show_edid_data(stdout, &edid[0], 128, 0); 875 show_edid_data(stdout, &edid[0], 128, 0);
875 if (edid[126] > 0) 876 if (edid[126] > 0)
876 show_edid_data(stdout, &edid[128], 128, 128); 877 show_edid_data(stdout, &edid[128], 128, 128);
877 show_edid(stdout, &edid[0], (edid[126] > 0) ? 1:0); 878 show_edid(stdout, &edid[0], (edid[126] > 0) ? 1:0);
878 } 879 }
879 if (force_mode >= 0) { 880 if (force_mode >= 0) {
880 mon_timing = &known_modes[force_mode]; 881 mon_timing = &known_modes[force_mode];
881 aspect = find_aspect(mon_timing->ha, mon_timing->va); 882 aspect = find_aspect(mon_timing->ha, mon_timing->va);
882 enable_audio = 1; 883 enable_audio = 1;
884 if (verbose) printf("Force mode %d with aspect %d\n",
885 force_mode, aspect);
883 why_res = "Mode forced on command line"; 886 why_res = "Mode forced on command line";
884 why_aud = "Audio forced on"; 887 why_aud = "Audio forced on";
885 } else if ((forcen_x == 0) && 888 } else if ((forcen_x == 0) &&
886 get_native(&edid[0], &prefer, &aspect, forcen_a, verbose)){ 889 get_native(&edid[0], &prefer, &aspect, forcen_a, verbose)){
887 mon_timing = &prefer; 890 mon_timing = &prefer;
888 why_res = "preferred/native resolution requested in EDID"; 891 why_res = "preferred/native resolution requested in EDID";
889 892
890 /* HDMI TVs tend to assume overscan (i.e. junk round the real frame)*/ 893 /* HDMI TVs tend to assume overscan (i.e. junk round the real frame)*/
891 /* even when we tell them otherwise with the AVI INFO frame */ 894 /* even when we tell them otherwise with the AVI INFO frame */
892 /* even if they set the 'underscan' flag that says they should */ 895 /* even if they set the 'underscan' flag that says they should */
(...skipping 24 matching lines...) Expand all
917 printf("%s: Fall back to default output 640x480@60\n", argv[0]); 920 printf("%s: Fall back to default output 640x480@60\n", argv[0]);
918 why_res = "default resolution because nothing better was identified"; 921 why_res = "default resolution because nothing better was identified";
919 /* First in table is default 640x480@60 */ 922 /* First in table is default 640x480@60 */
920 mon_timing = known_modes; 923 mon_timing = known_modes;
921 aspect = ASPECT_4_3; 924 aspect = ASPECT_4_3;
922 } 925 }
923 if (verbose) { 926 if (verbose) {
924 show_ch_timing(&lcd_timing, "input (laptop lcd)"); 927 show_ch_timing(&lcd_timing, "input (laptop lcd)");
925 show_ch_timing(mon_timing, "output (hdmi port)"); 928 show_ch_timing(mon_timing, "output (hdmi port)");
926 } 929 }
927 if (width_fix != NULL) 930 if ((width_fix != NULL) && (aspect >= 0))
928 new_width = width_fix[aspect]; 931 new_width = width_fix[aspect];
929 else 932 else
930 new_width = xmode->width; 933 new_width = xmode->width;
931 934
932 lcd_timing.ha = new_width; 935 lcd_timing.ha = new_width;
933 lcd_timing.ho = xmode->hSyncStart - new_width; 936 lcd_timing.ho = xmode->hSyncStart - new_width;
934 937
935 set_ch7036_config(i2cdev); 938 set_ch7036_config(i2cdev);
936 err = GenTableCH7036(&lcd_timing, mon_timing, &reglist); 939 err = GenTableCH7036(&lcd_timing, mon_timing, &reglist);
937 940
(...skipping 29 matching lines...) Expand all
967 ch_write_reg_sequence(i2cdev, reglist); 970 ch_write_reg_sequence(i2cdev, reglist);
968 ch_calculate_incs(i2cdev); 971 ch_calculate_incs(i2cdev);
969 ch_monitor_on(i2cdev); 972 ch_monitor_on(i2cdev);
970 /* Audio requires HDMI selected rather than DVI */ 973 /* Audio requires HDMI selected rather than DVI */
971 /* reset datapath (in monitor on) seems to zap this bit */ 974 /* reset datapath (in monitor on) seems to zap this bit */
972 if (enable_audio) { 975 if (enable_audio) {
973 ch_write_reg(i2cdev, CH7036_PWRST5, 0x4); 976 ch_write_reg(i2cdev, CH7036_PWRST5, 0x4);
974 } 977 }
975 hdmiOn = 1; 978 hdmiOn = 1;
976 979
977 if (new_width != xmode->width) 980 if (new_width != xmode->width) {
981 if (verbose) printf("Change X active width to %d\n", new_width);
978 set_x_size(dpy, root, new_width, xmode->height, 1, bwin); 982 set_x_size(dpy, root, new_width, xmode->height, 1, bwin);
983 }
979 if (verbose) printf("Monitor should be on!\n"); 984 if (verbose) printf("Monitor should be on!\n");
980 if ((edidlog = fopen(EDID_LOG, "w")) != NULL) { 985 if ((edidlog = fopen(EDID_LOG, "w")) != NULL) {
981 fprintf(edidlog, "HDMI output %dx%d%s. Use %dx%d on local LCD.\n", 986 fprintf(edidlog, "HDMI output %dx%d%s. Use %dx%d on local LCD.\n",
982 mon_timing->ha, mon_timing->va, 987 mon_timing->ha, mon_timing->va,
983 (mon_timing->scale != MK_SCALE(0,0)) ? "(scaled)":"", 988 (mon_timing->scale != MK_SCALE(0,0)) ? "(scaled)":"",
984 new_width, xmode->height); 989 new_width, xmode->height);
985 fprintf(edidlog, "Use %s\n", why_res); 990 fprintf(edidlog, "Use %s\n", why_res);
986 fprintf(edidlog, "%s audio pass through because %s\n\n", 991 fprintf(edidlog, "%s audio pass through because %s\n\n",
987 enable_audio ? "Enable" : "No", why_aud); 992 enable_audio ? "Enable" : "No", why_aud);
988 fprintf(edidlog, "EDID Data read from HDMI:\n"); 993 fprintf(edidlog, "EDID Data read from HDMI:\n");
(...skipping 30 matching lines...) Expand all
1019 } 1024 }
1020 if (verbose) printf("Monitor back on with DPMS On\n"); 1025 if (verbose) printf("Monitor back on with DPMS On\n");
1021 hdmiOn = 1; 1026 hdmiOn = 1;
1022 } 1027 }
1023 } 1028 }
1024 /* If we need a reload, don't wait! -- moved sleep to start for fw 1.2 */ 1029 /* If we need a reload, don't wait! -- moved sleep to start for fw 1.2 */
1025 // if (!needReload) sleep(5); 1030 // if (!needReload) sleep(5);
1026 } while (!needReload && ch_hdmi_detected(i2cdev)); 1031 } while (!needReload && ch_hdmi_detected(i2cdev));
1027 if (verbose) printf("Exit displaying needReload = %d, hdmiOn = %d\n", 1032 if (verbose) printf("Exit displaying needReload = %d, hdmiOn = %d\n",
1028 needReload, hdmiOn); 1033 needReload, hdmiOn);
1029 if (new_width != xmode->width) 1034 if (new_width != xmode->width) {
1035 if (verbose) printf("Change X active width to %d\n", xmode->width);
1030 set_x_size(dpy, root, xmode->width, xmode->height, 0, bwin); 1036 set_x_size(dpy, root, xmode->width, xmode->height, 0, bwin);
1037 }
1031 if (hdmiOn && !needReload) { 1038 if (hdmiOn && !needReload) {
1032 ch_monitor_off_keep_ddc(i2cdev); 1039 ch_monitor_off_keep_ddc(i2cdev);
1033 hdmiOn = 0; 1040 hdmiOn = 0;
1034 if (verbose) printf("Monitor should be off!\n"); 1041 if (verbose) printf("Monitor should be off!\n");
1035 sleep(YIELD_CHRONTEL_TURN_OFF_SECS); 1042 sleep(YIELD_CHRONTEL_TURN_OFF_SECS);
1036 } 1043 }
1037 } 1044 }
1038 close(i2cdev); 1045 close(i2cdev);
1039 return 0; 1046 return 0;
1040 } 1047 }
1041 1048
1042 1049
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698