Module Name:    src
Committed By:   jmcneill
Date:           Sat Nov 14 13:27:29 UTC 2015

Modified Files:
        src/sys/external/bsd/drm2/dist/drm: drm_fb_helper.c drm_modes.c

Log Message:
Support command-line modes by picking up connector modes from the device
properties. The connector name is the key name in the device properties
dictionary.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c
cvs rdiff -u -r1.5 -r1.6 src/sys/external/bsd/drm2/dist/drm/drm_modes.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c:1.7 src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c:1.8
--- src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c:1.7	Thu Jul 24 21:36:39 2014
+++ src/sys/external/bsd/drm2/dist/drm/drm_fb_helper.c	Sat Nov 14 13:27:29 2015
@@ -117,7 +117,6 @@ fail:
 }
 EXPORT_SYMBOL(drm_fb_helper_single_add_all_connectors);
 
-#ifndef __NetBSD__		/* XXX fb command line */
 static int drm_fb_helper_parse_command_line(struct drm_fb_helper *fb_helper)
 {
 	struct drm_fb_helper_connector *fb_helper_conn;
@@ -133,8 +132,14 @@ static int drm_fb_helper_parse_command_l
 		mode = &fb_helper_conn->cmdline_mode;
 
 		/* do something on return - turn off connector maybe */
+#if defined(__NetBSD__)
+		prop_dictionary_t prop = device_properties(connector->dev->dev);
+		if (prop_dictionary_get_cstring(prop, drm_get_connector_name(connector), &option) == false)
+			continue;
+#else
 		if (fb_get_options(drm_get_connector_name(connector), &option))
 			continue;
+#endif
 
 		if (drm_mode_parse_command_line_for_connector(option,
 							      connector,
@@ -171,7 +176,6 @@ static int drm_fb_helper_parse_command_l
 	}
 	return 0;
 }
-#endif
 
 static void drm_fb_helper_save_lut_atomic(struct drm_crtc *crtc, struct drm_fb_helper *helper)
 {
@@ -1207,9 +1211,6 @@ static bool drm_has_cmdline_mode(struct 
 struct drm_display_mode *drm_pick_cmdline_mode(struct drm_fb_helper_connector *fb_helper_conn,
 						      int width, int height)
 {
-#ifdef __NetBSD__		/* XXX fb command line */
-	return NULL;
-#else
 	struct drm_cmdline_mode *cmdline_mode;
 	struct drm_display_mode *mode = NULL;
 	bool prefer_non_interlace;
@@ -1257,7 +1258,6 @@ create_mode:
 						 cmdline_mode);
 	list_add(&mode->head, &fb_helper_conn->connector->modes);
 	return mode;
-#endif
 }
 EXPORT_SYMBOL(drm_pick_cmdline_mode);
 
@@ -1601,9 +1601,7 @@ bool drm_fb_helper_initial_config(struct
 	struct drm_device *dev = fb_helper->dev;
 	int count = 0;
 
-#ifndef __NetBSD__		/* XXX fb command line */
 	drm_fb_helper_parse_command_line(fb_helper);
-#endif
 
 	mutex_lock(&dev->mode_config.mutex);
 	count = drm_fb_helper_probe_connector_modes(fb_helper,

Index: src/sys/external/bsd/drm2/dist/drm/drm_modes.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_modes.c:1.5 src/sys/external/bsd/drm2/dist/drm/drm_modes.c:1.6
--- src/sys/external/bsd/drm2/dist/drm/drm_modes.c:1.5	Wed Jul 16 20:56:24 2014
+++ src/sys/external/bsd/drm2/dist/drm/drm_modes.c	Sat Nov 14 13:27:29 2015
@@ -1057,8 +1057,6 @@ void drm_mode_connector_list_update(stru
 }
 EXPORT_SYMBOL(drm_mode_connector_list_update);
 
-#ifndef __NetBSD__
-
 /**
  * drm_mode_parse_command_line_for_connector - parse command line modeline for connector
  * @mode_option: optional per connector mode option
@@ -1087,16 +1085,18 @@ bool drm_mode_parse_command_line_for_con
 	const char *name;
 	unsigned int namelen;
 	bool res_specified = false, bpp_specified = false, refresh_specified = false;
-	unsigned int xres = 0, yres = 0, bpp = 32, refresh = 0;
+	long xres = 0, yres = 0, bpp = 32, refresh = 0;
 	bool yres_specified = false, cvt = false, rb = false;
 	bool interlace = false, margins = false, was_digit = false;
 	int i;
 	enum drm_connector_force force = DRM_FORCE_UNSPECIFIED;
 
+#if !defined(__NetBSD__)
 #ifdef CONFIG_FB
 	if (!mode_option)
 		mode_option = fb_mode_option;
 #endif
+#endif
 
 	if (!mode_option) {
 		mode->specified = false;
@@ -1110,26 +1110,35 @@ bool drm_mode_parse_command_line_for_con
 		case '@':
 			if (!refresh_specified && !bpp_specified &&
 			    !yres_specified && !cvt && !rb && was_digit) {
-				refresh = simple_strtol(&name[i+1], NULL, 10);
-				refresh_specified = true;
-				was_digit = false;
+				if (kstrtol(&name[i+1], 10, &refresh) == 0) {
+					refresh_specified = true;
+					was_digit = false;
+				} else {
+					goto done;
+				}
 			} else
 				goto done;
 			break;
 		case '-':
 			if (!bpp_specified && !yres_specified && !cvt &&
 			    !rb && was_digit) {
-				bpp = simple_strtol(&name[i+1], NULL, 10);
-				bpp_specified = true;
-				was_digit = false;
+				if (kstrtol(&name[i+1], 10, &bpp) == 0) {
+					bpp_specified = true;
+					was_digit = false;
+				} else {
+					goto done;
+				}
 			} else
 				goto done;
 			break;
 		case 'x':
 			if (!yres_specified && was_digit) {
-				yres = simple_strtol(&name[i+1], NULL, 10);
-				yres_specified = true;
-				was_digit = false;
+				if (kstrtol(&name[i+1], 10, &yres) == 0) {
+					yres_specified = true;
+					was_digit = false;
+				} else {
+					goto done;
+				}
 			} else
 				goto done;
 			break;
@@ -1187,8 +1196,8 @@ bool drm_mode_parse_command_line_for_con
 	}
 
 	if (i < 0 && yres_specified) {
-		char *ch;
-		xres = simple_strtol(name, &ch, 10);
+		char *ch = NULL;
+		xres = strtoll(name, &ch, 10);
 		if ((ch != NULL) && (*ch == 'x'))
 			res_specified = true;
 		else
@@ -1199,7 +1208,7 @@ bool drm_mode_parse_command_line_for_con
 	}
 done:
 	if (i >= 0) {
-		printk(KERN_WARNING
+		DRM_ERROR(
 			"parse error at position %i in video mode '%s'\n",
 			i, name);
 		mode->specified = false;
@@ -1264,5 +1273,3 @@ drm_mode_create_from_cmdline_mode(struct
 	return mode;
 }
 EXPORT_SYMBOL(drm_mode_create_from_cmdline_mode);
-
-#endif

Reply via email to