[PATCH v6 03/23] modetest: Sort command line arguments
The current mostly random sort order hinders code readability. Sort the options alphabetically in the code, and by group in the help message. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com Reviewed-by: Jani Nikula jani.nik...@intel.com --- tests/modetest/modetest.c | 49 ++- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index e0d7d72..2bb4b19 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -835,8 +835,6 @@ set_mode(struct connector *c, int count, struct plane *p, int plane_count, kms_destroy(kms); } -static char optstr[] = ecpmfs:P:v; - #define min(a, b) ((a) (b) ? (a) : (b)) static int parse_connector(struct connector *c, const char *arg) @@ -896,15 +894,20 @@ static int parse_plane(struct plane *p, const char *arg) static void usage(char *name) { - fprintf(stderr, usage: %s [-ecpmf]\n, name); - fprintf(stderr, \t-e\tlist encoders\n); + fprintf(stderr, usage: %s [-cefmPpsv]\n, name); + + fprintf(stderr, \n Query options:\n\n); fprintf(stderr, \t-c\tlist connectors\n); - fprintf(stderr, \t-p\tlist CRTCs and planes (pipes)\n); - fprintf(stderr, \t-m\tlist modes\n); + fprintf(stderr, \t-e\tlist encoders\n); fprintf(stderr, \t-f\tlist framebuffers\n); - fprintf(stderr, \t-v\ttest vsynced page flipping\n); - fprintf(stderr, \t-s connector_id[@crtc_id]:mode[@format]\tset a mode\n); + fprintf(stderr, \t-m\tlist modes\n); + fprintf(stderr, \t-p\tlist CRTCs and planes (pipes)\n); + + fprintf(stderr, \n Test options:\n\n); fprintf(stderr, \t-P connector_id:wxh[@format]\tset a plane\n); + fprintf(stderr, \t-s connector_id[@crtc_id]:mode[@format]\tset a mode\n); + fprintf(stderr, \t-v\ttest vsynced page flipping\n); + fprintf(stderr, \n\tDefault is to dump all info.\n); exit(0); } @@ -932,6 +935,8 @@ static int page_flipping_supported(void) #endif } +static char optstr[] = cefmP:ps:v; + int main(int argc, char **argv) { int c; @@ -946,34 +951,34 @@ int main(int argc, char **argv) opterr = 0; while ((c = getopt(argc, argv, optstr)) != -1) { switch (c) { - case 'e': - encoders = 1; - break; case 'c': connectors = 1; break; - case 'p': - crtcs = 1; - planes = 1; + case 'e': + encoders = 1; + break; + case 'f': + framebuffers = 1; break; case 'm': modes = 1; break; - case 'f': - framebuffers = 1; + case 'P': + if (parse_plane(plane_args[plane_count], optarg) 0) + usage(argv[0]); + plane_count++; break; - case 'v': - test_vsync = 1; + case 'p': + crtcs = 1; + planes = 1; break; case 's': if (parse_connector(con_args[count], optarg) 0) usage(argv[0]); count++; break; - case 'P': - if (parse_plane(plane_args[plane_count], optarg) 0) - usage(argv[0]); - plane_count++; + case 'v': + test_vsync = 1; break; default: usage(argv[0]); -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v6 05/23] modetest: Add a command line parameter to drop master after mode set
If the -d parameter is specified, modetest will drop master permissions after setting the mode. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 5802c8e..218d26a 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -894,7 +894,7 @@ static int parse_plane(struct plane *p, const char *arg) static void usage(char *name) { - fprintf(stderr, usage: %s [-cefMmPpsv]\n, name); + fprintf(stderr, usage: %s [-cdefMmPpsv]\n, name); fprintf(stderr, \n Query options:\n\n); fprintf(stderr, \t-c\tlist connectors\n); @@ -909,6 +909,7 @@ static void usage(char *name) fprintf(stderr, \t-v\ttest vsynced page flipping\n); fprintf(stderr, \n Generic options:\n\n); + fprintf(stderr, \t-d\tdrop master after mode set\n); fprintf(stderr, \t-M module\tuse the given driver\n); fprintf(stderr, \n\tDefault is to dump all info.\n); @@ -938,12 +939,13 @@ static int page_flipping_supported(void) #endif } -static char optstr[] = cefM:mP:ps:v; +static char optstr[] = cdefM:mP:ps:v; int main(int argc, char **argv) { int c; int encoders = 0, connectors = 0, crtcs = 0, planes = 0, framebuffers = 0; + int drop_master = 0; int test_vsync = 0; const char *modules[] = { i915, radeon, nouveau, vmwgfx, omapdrm, exynos }; char *module = NULL; @@ -961,6 +963,9 @@ int main(int argc, char **argv) case 'c': connectors = 1; break; + case 'd': + drop_master = 1; + break; case 'e': encoders = 1; break; @@ -1046,6 +1051,8 @@ int main(int argc, char **argv) if (count 0) { set_mode(con_args, count, plane_args, plane_count, test_vsync); + if (drop_master) + drmDropMaster(fd); getchar(); } -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v6 06/23] modetest: Retrieve all resources in one go
Instead of retrieving resources as they are needed, retrieve them all (except property blobs) in one go at startup. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 408 +- 1 file changed, 261 insertions(+), 147 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 218d26a..8ad138e 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -57,7 +57,44 @@ #include buffers.h -drmModeRes *resources; +struct crtc { + drmModeCrtc *crtc; + drmModeObjectProperties *props; + drmModePropertyRes **props_info; +}; + +struct encoder { + drmModeEncoder *encoder; +}; + +struct connector { + drmModeConnector *connector; + drmModeObjectProperties *props; + drmModePropertyRes **props_info; +}; + +struct fb { + drmModeFB *fb; +}; + +struct plane { + drmModePlane *plane; + drmModeObjectProperties *props; + drmModePropertyRes **props_info; +}; + +struct resources { + drmModeRes *res; + drmModePlaneRes *plane_res; + + struct crtc *crtcs; + struct encoder *encoders; + struct connector *connectors; + struct fb *fbs; + struct plane *planes; +}; + +struct resources *resources; int fd, modes; #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -166,21 +203,17 @@ static void dump_encoders(void) printf(Encoders:\n); printf(id\tcrtc\ttype\tpossible crtcs\tpossible clones\t\n); - for (i = 0; i resources-count_encoders; i++) { - encoder = drmModeGetEncoder(fd, resources-encoders[i]); - - if (!encoder) { - fprintf(stderr, could not get encoder %i: %s\n, - resources-encoders[i], strerror(errno)); + for (i = 0; i resources-res-count_encoders; i++) { + encoder = resources-encoders[i].encoder; + if (!encoder) continue; - } + printf(%d\t%d\t%s\t0x%08x\t0x%08x\n, encoder-encoder_id, encoder-crtc_id, encoder_type_str(encoder-encoder_type), encoder-possible_crtcs, encoder-possible_clones); - drmModeFreeEncoder(encoder); } printf(\n); } @@ -230,13 +263,9 @@ dump_blob(uint32_t blob_id) } static void -dump_prop(uint32_t prop_id, uint64_t value) +dump_prop(drmModePropertyPtr prop, uint32_t prop_id, uint64_t value) { int i; - drmModePropertyPtr prop; - - prop = drmModeGetProperty(fd, prop_id); - printf(\t%d, prop_id); if (!prop) { printf(\n); @@ -297,25 +326,19 @@ dump_prop(uint32_t prop_id, uint64_t value) dump_blob(value); else printf( %PRIu64\n, value); - - drmModeFreeProperty(prop); } static void dump_connectors(void) { - drmModeConnector *connector; int i, j; printf(Connectors:\n); printf(id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\tencoders\n); - for (i = 0; i resources-count_connectors; i++) { - connector = drmModeGetConnector(fd, resources-connectors[i]); - - if (!connector) { - fprintf(stderr, could not get connector %i: %s\n, - resources-connectors[i], strerror(errno)); + for (i = 0; i resources-res-count_connectors; i++) { + struct connector *_connector = resources-connectors[i]; + drmModeConnector *connector = _connector-connector; + if (!connector) continue; - } printf(%d\t%d\t%s\t%s\t%dx%d\t\t%d\t, connector-connector_id, @@ -335,35 +358,32 @@ static void dump_connectors(void) vss vse vtot)\n); for (j = 0; j connector-count_modes; j++) dump_mode(connector-modes[j]); + } + if (_connector-props) { printf( props:\n); - for (j = 0; j connector-count_props; j++) - dump_prop(connector-props[j], - connector-prop_values[j]); + for (j = 0; j (int)_connector-props-count_props; j++) + dump_prop(_connector-props_info[j], + _connector-props-props[j], + _connector-props-prop_values[j]); } - - drmModeFreeConnector(connector); } printf(\n); } static void dump_crtcs(void) { - drmModeCrtc *crtc; - drmModeObjectPropertiesPtr props; int i; uint32_t j; printf
[PATCH v6 08/23] modetest: Add a command line parameter to set properties
The -w parameter can be used to set a property value from the command line, using the target object ID and the property name. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 108 +- 1 file changed, 106 insertions(+), 2 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 778af62..858d480 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -709,6 +709,80 @@ connector_find_mode(struct connector_arg *c) } +/* - + * Properties + */ + +struct property_arg { + uint32_t obj_id; + uint32_t obj_type; + char name[DRM_PROP_NAME_LEN+1]; + uint32_t prop_id; + uint64_t value; +}; + +static void set_property(struct property_arg *p) +{ + drmModeObjectProperties *props; + drmModePropertyRes **props_info; + const char *obj_type; + int ret; + int i; + + p-obj_type = 0; + p-prop_id = 0; + +#define find_object(_res, __res, type, Type) \ + do { \ + for (i = 0; i (int)(_res)-__res-count_##type##s; ++i) { \ + struct type *obj = (_res)-type##s[i]; \ + if (obj-type-type##_id != p-obj_id) \ + continue; \ + p-obj_type = DRM_MODE_OBJECT_##Type; \ + obj_type = #Type; \ + props = obj-props; \ + props_info = obj-props_info; \ + } \ + } while(0) \ + + find_object(resources, res, crtc, CRTC); + if (p-obj_type == 0) + find_object(resources, res, connector, CONNECTOR); + if (p-obj_type == 0) + find_object(resources, plane_res, plane, PLANE); + if (p-obj_type == 0) { + fprintf(stderr, Object %i not found, can't set property\n, + p-obj_id); + return; + } + + if (!props) { + fprintf(stderr, %s %i has no properties\n, + obj_type, p-obj_id); + return; + } + + for (i = 0; i (int)props-count_props; ++i) { + if (!props_info[i]) + continue; + if (strcmp(props_info[i]-name, p-name) == 0) + break; + } + + if (i == (int)props-count_props) { + fprintf(stderr, %s %i has no %s property\n, + obj_type, p-obj_id, p-name); + return; + } + + p-prop_id = props-props[i]; + + ret = drmModeObjectSetProperty(fd, p-obj_id, p-obj_type, p-prop_id, p-value); + if (ret 0) + fprintf(stderr, failed to set %s %i property %s to % PRIu64 : %s\n, + obj_type, p-obj_id, p-name, p-value, strerror(errno)); +} + /* -- */ static void @@ -1008,9 +1082,20 @@ static int parse_plane(struct plane_arg *p, const char *arg) return 0; } +static int parse_property(struct property_arg *p, const char *arg) +{ + if (sscanf(arg, %d:%32[^:]:% SCNu64, p-obj_id, p-name, p-value) != 3) + return -1; + + p-obj_type = 0; + p-name[DRM_PROP_NAME_LEN] = '\0'; + + return 0; +} + static void usage(char *name) { - fprintf(stderr, usage: %s [-cdefMmPpsv]\n, name); + fprintf(stderr, usage: %s [-cdefMmPpsvw]\n, name); fprintf(stderr, \n Query options:\n\n); fprintf(stderr, \t-c\tlist connectors\n); @@ -1023,6 +1108,7 @@ static void usage(char *name) fprintf(stderr, \t-P connector_id:wxh[@format]\tset a plane\n); fprintf(stderr, \t-s connector_id[@crtc_id]:mode[@format]\tset a mode\n); fprintf(stderr, \t-v\ttest vsynced page flipping\n); + fprintf(stderr, \t-w obj_id:prop_name:value\tset property\n); fprintf(stderr, \n Generic options:\n\n); fprintf(stderr, \t-d\tdrop master after mode set\n); @@ -1055,7 +1141,7 @@ static int page_flipping_supported(void) #endif } -static char optstr[] = cdefM:mP:ps:v; +static char optstr[] = cdefM:mP:ps:vw:; int main(int argc, char **argv) { @@ -1067,8 +1153,10 @@ int main(int argc, char **argv) char *module = NULL; unsigned int i; int count = 0, plane_count = 0; + unsigned int prop_count = 0; struct connector_arg *con_args = NULL
[PATCH v6 09/23] modetest: Allow specifying plane position
Extend the -P option to allow specifying the plane x and y offsets. The position is optional, if not specified the plane will be positioned at the center of the screen as before. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 67 --- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 858d480..897a66c 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -40,6 +40,7 @@ #include config.h #include assert.h +#include stdbool.h #include stdio.h #include stdlib.h #include stdint.h @@ -645,6 +646,8 @@ struct connector_arg { struct plane_arg { uint32_t con_id; /* the id of connector to bind to */ + bool has_position; + int32_t x, y; uint32_t w, h; unsigned int fb_id; char format_str[5]; /* need to leave room for terminating \0 */ @@ -855,11 +858,16 @@ set_plane(struct kms_driver *kms, struct connector_arg *c, struct plane_arg *p) return -1; } - /* ok, boring.. but for now put in middle of screen: */ - crtc_x = c-mode-hdisplay / 3; - crtc_y = c-mode-vdisplay / 3; - crtc_w = crtc_x; - crtc_h = crtc_y; + if (!p-has_position) { + /* Default to the middle of the screen */ + crtc_x = (c-mode-hdisplay - p-w) / 2; + crtc_y = (c-mode-vdisplay - p-h) / 2; + } else { + crtc_x = p-x; + crtc_y = p-y; + } + crtc_w = p-w; + crtc_h = p-h; /* note src coords (last 4 args) are in Q16 format */ if (drmModeSetPlane(fd, plane_id, c-crtc, p-fb_id, @@ -1065,18 +1073,47 @@ static int parse_connector(struct connector_arg *c, const char *arg) return 0; } -static int parse_plane(struct plane_arg *p, const char *arg) +static int parse_plane(struct plane_arg *plane, const char *p) { - strcpy(p-format_str, XR24); + char *end; - if (sscanf(arg, %d:%dx%d@%4s, p-con_id, p-w, p-h, p-format_str) != 4 - sscanf(arg, %d:%dx%d, p-con_id, p-w, p-h) != 3) - return -1; + memset(plane, 0, sizeof *plane); - p-fourcc = format_fourcc(p-format_str); - if (p-fourcc == 0) { - fprintf(stderr, unknown format %s\n, p-format_str); - return -1; + plane-con_id = strtoul(p, end, 10); + if (*end != ':') + return -EINVAL; + + p = end + 1; + plane-w = strtoul(p, end, 10); + if (*end != 'x') + return -EINVAL; + + p = end + 1; + plane-h = strtoul(p, end, 10); + + if (*end == '+' || *end == '-') { + plane-x = strtol(end, end, 10); + if (*end != '+' *end != '-') + return -EINVAL; + plane-y = strtol(end, end, 10); + + plane-has_position = true; + } + + if (*end == '@') { + p = end + 1; + if (strlen(p) != 4) + return -EINVAL; + + strcpy(plane-format_str, p); + } else { + strcpy(plane-format_str, XR24); + } + + plane-fourcc = format_fourcc(plane-format_str); + if (plane-fourcc == 0) { + fprintf(stderr, unknown format %s\n, plane-format_str); + return -EINVAL; } return 0; @@ -1105,7 +1142,7 @@ static void usage(char *name) fprintf(stderr, \t-p\tlist CRTCs and planes (pipes)\n); fprintf(stderr, \n Test options:\n\n); - fprintf(stderr, \t-P connector_id:wxh[@format]\tset a plane\n); + fprintf(stderr, \t-P connector_id:wxh[+x+y][@format]\tset a plane\n); fprintf(stderr, \t-s connector_id[@crtc_id]:mode[@format]\tset a mode\n); fprintf(stderr, \t-v\ttest vsynced page flipping\n); fprintf(stderr, \t-w obj_id:prop_name:value\tset property\n); -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v6 10/23] modetest: Print the plane ID when setting up a plane
As modetest automatically selects an unused plan, providing the plane ID allows modifying plane properties for the selected planes. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 897a66c..7f7a3a2 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -838,14 +838,14 @@ set_plane(struct kms_driver *kms, struct connector_arg *c, struct plane_arg *p) plane_id = ovr-plane_id; } - fprintf(stderr, testing %dx%d@%s overlay plane\n, - p-w, p-h, p-format_str); - if (!plane_id) { - fprintf(stderr, failed to find plane!\n); + fprintf(stderr, no unused plane available for CRTC %u\n, c-crtc); return -1; } + fprintf(stderr, testing %dx%d@%s overlay plane %u\n, + p-w, p-h, p-format_str, plane_id); + plane_bo = create_test_buffer(kms, p-fourcc, p-w, p-h, handles, pitches, offsets, PATTERN_TILES); if (plane_bo == NULL) -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v6 11/23] modetest: Remove the -m argument
The argument isn't used, remove it. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 7f7a3a2..89bfc53 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -96,7 +96,7 @@ struct resources { }; struct resources *resources; -int fd, modes; +int fd; #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -1138,7 +1138,6 @@ static void usage(char *name) fprintf(stderr, \t-c\tlist connectors\n); fprintf(stderr, \t-e\tlist encoders\n); fprintf(stderr, \t-f\tlist framebuffers\n); - fprintf(stderr, \t-m\tlist modes\n); fprintf(stderr, \t-p\tlist CRTCs and planes (pipes)\n); fprintf(stderr, \n Test options:\n\n); @@ -1178,7 +1177,7 @@ static int page_flipping_supported(void) #endif } -static char optstr[] = cdefM:mP:ps:vw:; +static char optstr[] = cdefM:P:ps:vw:; int main(int argc, char **argv) { @@ -1218,9 +1217,6 @@ int main(int argc, char **argv) /* Preserve the default behaviour of dumping all information. */ args--; break; - case 'm': - modes = 1; - break; case 'P': plane_args = realloc(plane_args, (plane_count + 1) * sizeof *plane_args); @@ -1274,7 +1270,7 @@ int main(int argc, char **argv) } if (!args) - encoders = connectors = crtcs = planes = modes = framebuffers = 1; + encoders = connectors = crtcs = planes = framebuffers = 1; if (module) { fd = drmOpen(module, NULL); -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v6 12/23] modetest: Create a device structure
Instead of passing the device fd and resources as global variables group them in a device structure and pass it explictly to all functions that need it. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 201 -- 1 file changed, 103 insertions(+), 98 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 89bfc53..cfcb989 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -95,8 +95,12 @@ struct resources { struct plane *planes; }; -struct resources *resources; -int fd; +struct device { + int fd; + + struct resources *resources; + struct kms_driver *kms; +}; #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -197,15 +201,15 @@ static const char *mode_flag_names[] = { static bit_name_fn(mode_flag) -static void dump_encoders(void) +static void dump_encoders(struct device *dev) { drmModeEncoder *encoder; int i; printf(Encoders:\n); printf(id\tcrtc\ttype\tpossible crtcs\tpossible clones\t\n); - for (i = 0; i resources-res-count_encoders; i++) { - encoder = resources-encoders[i].encoder; + for (i = 0; i dev-resources-res-count_encoders; i++) { + encoder = dev-resources-encoders[i].encoder; if (!encoder) continue; @@ -240,14 +244,13 @@ static void dump_mode(drmModeModeInfo *mode) printf(\n); } -static void -dump_blob(uint32_t blob_id) +static void dump_blob(struct device *dev, uint32_t blob_id) { uint32_t i; unsigned char *blob_data; drmModePropertyBlobPtr blob; - blob = drmModeGetPropertyBlob(fd, blob_id); + blob = drmModeGetPropertyBlob(dev-fd, blob_id); if (!blob) return; @@ -263,8 +266,8 @@ dump_blob(uint32_t blob_id) drmModeFreePropertyBlob(blob); } -static void -dump_prop(drmModePropertyPtr prop, uint32_t prop_id, uint64_t value) +static void dump_prop(struct device *dev, drmModePropertyPtr prop, + uint32_t prop_id, uint64_t value) { int i; printf(\t%d, prop_id); @@ -316,7 +319,7 @@ dump_prop(drmModePropertyPtr prop, uint32_t prop_id, uint64_t value) if (prop-flags DRM_MODE_PROP_BLOB) { printf(\t\tblobs:\n); for (i = 0; i prop-count_blobs; i++) - dump_blob(prop-blob_ids[i]); + dump_blob(dev, prop-blob_ids[i]); printf(\n); } else { assert(prop-count_blobs == 0); @@ -324,19 +327,19 @@ dump_prop(drmModePropertyPtr prop, uint32_t prop_id, uint64_t value) printf(\t\tvalue:); if (prop-flags DRM_MODE_PROP_BLOB) - dump_blob(value); + dump_blob(dev, value); else printf( %PRIu64\n, value); } -static void dump_connectors(void) +static void dump_connectors(struct device *dev) { int i, j; printf(Connectors:\n); printf(id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\tencoders\n); - for (i = 0; i resources-res-count_connectors; i++) { - struct connector *_connector = resources-connectors[i]; + for (i = 0; i dev-resources-res-count_connectors; i++) { + struct connector *_connector = dev-resources-connectors[i]; drmModeConnector *connector = _connector-connector; if (!connector) continue; @@ -364,7 +367,7 @@ static void dump_connectors(void) if (_connector-props) { printf( props:\n); for (j = 0; j (int)_connector-props-count_props; j++) - dump_prop(_connector-props_info[j], + dump_prop(dev, _connector-props_info[j], _connector-props-props[j], _connector-props-prop_values[j]); } @@ -372,15 +375,15 @@ static void dump_connectors(void) printf(\n); } -static void dump_crtcs(void) +static void dump_crtcs(struct device *dev) { int i; uint32_t j; printf(CRTCs:\n); printf(id\tfb\tpos\tsize\n); - for (i = 0; i resources-res-count_crtcs; i++) { - struct crtc *_crtc = resources-crtcs[i]; + for (i = 0; i dev-resources-res-count_crtcs; i++) { + struct crtc *_crtc = dev-resources-crtcs[i]; drmModeCrtc *crtc = _crtc-crtc; if (!crtc) continue; @@ -395,7 +398,7 @@ static void dump_crtcs(void) if (_crtc-props) { printf( props:\n); for (j = 0; j _crtc-props-count_props; j++) - dump_prop(_crtc-props_info[j
[PATCH v6 13/23] modetest: Compute CRTC pipe number as needed
Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 29 + 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index cfcb989..a1a683f 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -640,7 +640,6 @@ struct connector_arg { drmModeModeInfo *mode; drmModeEncoder *encoder; int crtc; - int pipe; unsigned int fb_id[2], current_fb_id; struct timeval start; @@ -703,15 +702,6 @@ static void connector_find_mode(struct device *dev, struct connector_arg *c) if (c-crtc == -1) c-crtc = c-encoder-crtc_id; - - /* and figure out which crtc index it is: */ - for (i = 0; i dev-resources-res-count_crtcs; i++) { - if (c-crtc == (int)dev-resources-res-crtcs[i]) { - c-pipe = i; - break; - } - } - } /* - @@ -829,15 +819,30 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) struct kms_bo *plane_bo; uint32_t plane_flags = 0; int crtc_x, crtc_y, crtc_w, crtc_h; + unsigned int pipe; unsigned int i; - /* find an unused plane which can be connected to our crtc */ + /* Find an unused plane which can be connected to our CRTC. Find the +* CRTC index first, then iterate over available planes. +*/ + for (i = 0; i (unsigned int)dev-resources-res-count_crtcs; i++) { + if (c-crtc == (int)dev-resources-res-crtcs[i]) { + pipe = i; + break; + } + } + + if (pipe == (unsigned int)dev-resources-res-count_crtcs) { + fprintf(stderr, CRTC %u not found\n, c-crtc); + return -1; + } + for (i = 0; i dev-resources-plane_res-count_planes !plane_id; i++) { ovr = dev-resources-planes[i].plane; if (!ovr) continue; - if ((ovr-possible_crtcs (1 c-pipe)) !ovr-crtc_id) + if ((ovr-possible_crtcs (1 pipe)) !ovr-crtc_id) plane_id = ovr-plane_id; } -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v6 14/23] modetest: Remove the struct connector_arg encoder field
The field is no needed, make it a local variable where used. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index a1a683f..2c3e093 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -638,7 +638,6 @@ struct connector_arg { char format_str[5]; unsigned int fourcc; drmModeModeInfo *mode; - drmModeEncoder *encoder; int crtc; unsigned int fb_id[2], current_fb_id; struct timeval start; @@ -659,6 +658,7 @@ struct plane_arg { static void connector_find_mode(struct device *dev, struct connector_arg *c) { drmModeConnector *connector; + drmModeEncoder *encoder; int i, j; /* First, find the connector mode */ @@ -692,16 +692,16 @@ static void connector_find_mode(struct device *dev, struct connector_arg *c) /* Now get the encoder */ for (i = 0; i dev-resources-res-count_encoders; i++) { - c-encoder = dev-resources-encoders[i].encoder; - if (!c-encoder) + encoder = dev-resources-encoders[i].encoder; + if (!encoder) continue; - if (c-encoder-encoder_id == connector-encoder_id) + if (encoder-encoder_id == connector-encoder_id) break; } if (c-crtc == -1) - c-crtc = c-encoder-crtc_id; + c-crtc = encoder-crtc_id; } /* - -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v6 15/23] modetest: Store the crtc in the connector_arg structure
This prepares the code for the split in separate functions of CRTC and planes setup. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 58 ++- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 2c3e093..6fbaf09 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -634,11 +634,12 @@ error: */ struct connector_arg { uint32_t id; + uint32_t crtc_id; char mode_str[64]; char format_str[5]; unsigned int fourcc; drmModeModeInfo *mode; - int crtc; + struct crtc *crtc; unsigned int fb_id[2], current_fb_id; struct timeval start; @@ -690,18 +691,33 @@ static void connector_find_mode(struct device *dev, struct connector_arg *c) return; } - /* Now get the encoder */ - for (i = 0; i dev-resources-res-count_encoders; i++) { - encoder = dev-resources-encoders[i].encoder; - if (!encoder) - continue; + /* If the CRTC ID was specified, get the corresponding CRTC. Otherwise +* locate a CRTC that can be attached to the connector. +*/ + if (c-crtc_id == (uint32_t)-1) { + for (i = 0; i dev-resources-res-count_encoders; i++) { + encoder = dev-resources-encoders[i].encoder; + if (!encoder) + continue; + + if (encoder-encoder_id == connector-encoder_id) { + c-crtc_id = encoder-crtc_id; + break; + } + } + } + + if (c-crtc_id == (uint32_t)-1) + return; - if (encoder-encoder_id == connector-encoder_id) + for (i = 0; i dev-resources-res-count_crtcs; i++) { + struct crtc *crtc = dev-resources-crtcs[i]; + + if (c-crtc_id == crtc-crtc-crtc_id) { + c-crtc = crtc; break; + } } - - if (c-crtc == -1) - c-crtc = encoder-crtc_id; } /* - @@ -796,7 +812,7 @@ page_flip_handler(int fd, unsigned int frame, else new_fb_id = c-fb_id[0]; - drmModePageFlip(fd, c-crtc, new_fb_id, + drmModePageFlip(fd, c-crtc_id, new_fb_id, DRM_MODE_PAGE_FLIP_EVENT, c); c-current_fb_id = new_fb_id; c-swap_count++; @@ -826,14 +842,14 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) * CRTC index first, then iterate over available planes. */ for (i = 0; i (unsigned int)dev-resources-res-count_crtcs; i++) { - if (c-crtc == (int)dev-resources-res-crtcs[i]) { + if (c-crtc_id == dev-resources-res-crtcs[i]) { pipe = i; break; } } if (pipe == (unsigned int)dev-resources-res-count_crtcs) { - fprintf(stderr, CRTC %u not found\n, c-crtc); + fprintf(stderr, CRTC %u not found\n, c-crtc_id); return -1; } @@ -847,7 +863,7 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) } if (!plane_id) { - fprintf(stderr, no unused plane available for CRTC %u\n, c-crtc); + fprintf(stderr, no unused plane available for CRTC %u\n, c-crtc_id); return -1; } @@ -878,7 +894,7 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) crtc_h = p-h; /* note src coords (last 4 args) are in Q16 format */ - if (drmModeSetPlane(dev-fd, plane_id, c-crtc, p-fb_id, + if (drmModeSetPlane(dev-fd, plane_id, c-crtc_id, p-fb_id, plane_flags, crtc_x, crtc_y, crtc_w, crtc_h, 0, 0, p-w 16, p-h 16)) { fprintf(stderr, failed to enable plane: %s\n, @@ -886,7 +902,7 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) return -1; } - ovr-crtc_id = c-crtc; + ovr-crtc_id = c-crtc_id; return 0; } @@ -930,9 +946,9 @@ static void set_mode(struct device *dev, struct connector_arg *c, int count, continue; printf(setting mode %s@%s on connector %d, crtc %d\n, - c[i].mode_str, c[i].format_str, c[i].id, c[i].crtc); + c[i].mode_str, c[i].format_str, c[i].id, c[i].crtc_id); - ret = drmModeSetCrtc(dev-fd, c[i].crtc, fb_id, x, 0, + ret = drmModeSetCrtc(dev-fd, c[i].crtc_id, fb_id, x, 0
[PATCH v6 16/23] modetest: Store the mode in the crtc structure
This prepares the code for the split in separate functions of CRTC and planes setup. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 6fbaf09..3de611e 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -62,6 +62,7 @@ struct crtc { drmModeCrtc *crtc; drmModeObjectProperties *props; drmModePropertyRes **props_info; + drmModeModeInfo *mode; }; struct encoder { @@ -524,6 +525,7 @@ static void free_resources(struct resources *res) static struct resources *get_resources(struct device *dev) { struct resources *res; + int i; res = malloc(sizeof *res); if (res == 0) @@ -598,6 +600,9 @@ static struct resources *get_resources(struct device *dev) get_properties(res, res, crtc, CRTC); get_properties(res, res, connector, CONNECTOR); + for (i = 0; i res-res-count_crtcs; ++i) + res-crtcs[i].mode = res-crtcs[i].crtc-mode; + res-plane_res = drmModeGetPlaneResources(dev-fd); if (!res-plane_res) { fprintf(stderr, drmModeGetPlaneResources failed: %s\n, @@ -714,6 +719,7 @@ static void connector_find_mode(struct device *dev, struct connector_arg *c) struct crtc *crtc = dev-resources-crtcs[i]; if (c-crtc_id == crtc-crtc-crtc_id) { + crtc-mode = c-mode; c-crtc = crtc; break; } @@ -884,8 +890,8 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) if (!p-has_position) { /* Default to the middle of the screen */ - crtc_x = (c-mode-hdisplay - p-w) / 2; - crtc_y = (c-mode-vdisplay - p-h) / 2; + crtc_x = (c-crtc-mode-hdisplay - p-w) / 2; + crtc_y = (c-crtc-mode-vdisplay - p-h) / 2; } else { crtc_x = p-x; crtc_y = p-y; -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v6 18/23] modetest: Split mode setting and plane setup
There's not reason to require setting a mode to test planes. Split the two operations. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 104 -- 1 file changed, 72 insertions(+), 32 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 1a48cc3..93a0864 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -101,6 +101,14 @@ struct device { struct resources *resources; struct kms_driver *kms; + + struct { + unsigned int width; + unsigned int height; + + unsigned int fb_id; + struct kms_bo *bo; + } mode; }; #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -840,7 +848,7 @@ static int set_plane(struct device *dev, struct plane_arg *p) struct kms_bo *plane_bo; uint32_t plane_flags = 0; int crtc_x, crtc_y, crtc_w, crtc_h; - struct crtc *crtc; + struct crtc *crtc = NULL; unsigned int pipe; unsigned int i; @@ -915,36 +923,37 @@ static int set_plane(struct device *dev, struct plane_arg *p) return 0; } -static void set_mode(struct device *dev, struct connector_arg *c, int count, -struct plane_arg *p, int plane_count, int page_flip) +static void set_mode(struct device *dev, struct connector_arg *c, unsigned int count) { - struct kms_bo *bo, *other_bo; - unsigned int fb_id, other_fb_id; - int i, j, ret, width, height, x; uint32_t handles[4], pitches[4], offsets[4] = {0}; /* we only use [0] */ - drmEventContext evctx; + unsigned int fb_id; + struct kms_bo *bo; + unsigned int i; + int ret, x; + + dev-mode.width = 0; + dev-mode.height = 0; - width = 0; - height = 0; for (i = 0; i count; i++) { connector_find_mode(dev, c[i]); if (c[i].mode == NULL) continue; - width += c[i].mode-hdisplay; - if (height c[i].mode-vdisplay) - height = c[i].mode-vdisplay; + dev-mode.width += c[i].mode-hdisplay; + if (dev-mode.height c[i].mode-vdisplay) + dev-mode.height = c[i].mode-vdisplay; } - bo = create_test_buffer(dev-kms, c-fourcc, width, height, handles, - pitches, offsets, PATTERN_SMPTE); + bo = create_test_buffer(dev-kms, c-fourcc, + dev-mode.width, dev-mode.height, + handles, pitches, offsets, PATTERN_SMPTE); if (bo == NULL) return; - ret = drmModeAddFB2(dev-fd, width, height, c-fourcc, + ret = drmModeAddFB2(dev-fd, dev-mode.width, dev-mode.height, c-fourcc, handles, pitches, offsets, fb_id, 0); if (ret) { fprintf(stderr, failed to add fb (%ux%u): %s\n, - width, height, strerror(errno)); + dev-mode.width, dev-mode.height, strerror(errno)); return; } @@ -968,24 +977,39 @@ static void set_mode(struct device *dev, struct connector_arg *c, int count, fprintf(stderr, failed to set mode: %s\n, strerror(errno)); return; } - - /* if we have a plane/overlay to show, set that up now: */ - for (j = 0; j plane_count; j++) - if (p[j].crtc_id == c[i].crtc_id) - if (set_plane(dev, p[j])) - return; } - if (!page_flip) - return; + dev-mode.bo = bo; + dev-mode.fb_id = fb_id; +} + +static void set_planes(struct device *dev, struct plane_arg *p, unsigned int count) +{ + unsigned int i; + + /* set up planes/overlays */ + for (i = 0; i count; i++) + if (set_plane(dev, p[i])) + return; +} + +static void test_page_flip(struct device *dev, struct connector_arg *c, unsigned int count) +{ + uint32_t handles[4], pitches[4], offsets[4] = {0}; /* we only use [0] */ + unsigned int other_fb_id; + struct kms_bo *other_bo; + drmEventContext evctx; + unsigned int i; + int ret; - other_bo = create_test_buffer(dev-kms, c-fourcc, width, height, handles, - pitches, offsets, PATTERN_PLAIN); + other_bo = create_test_buffer(dev-kms, c-fourcc, + dev-mode.width, dev-mode.height, + handles, pitches, offsets, PATTERN_PLAIN); if (other_bo == NULL) return; - ret = drmModeAddFB2(dev-fd, width, height, c-fourcc, handles, pitches, offsets
[PATCH v6 17/23] modetest: Give the CRTC ID to the -P option
Planes are associated with CRTCs, not connectors. Don't try to be too clever, use the CRTC ID in the -P option. This prepares for splitting CRTC and planes setup. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 32 +--- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 3de611e..1a48cc3 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -652,7 +652,7 @@ struct connector_arg { }; struct plane_arg { - uint32_t con_id; /* the id of connector to bind to */ + uint32_t crtc_id; /* the id of CRTC to bind to */ bool has_position; int32_t x, y; uint32_t w, h; @@ -832,8 +832,7 @@ page_flip_handler(int fd, unsigned int frame, } } -static int -set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) +static int set_plane(struct device *dev, struct plane_arg *p) { drmModePlane *ovr; uint32_t handles[4], pitches[4], offsets[4] = {0}; /* we only use [0] */ @@ -841,6 +840,7 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) struct kms_bo *plane_bo; uint32_t plane_flags = 0; int crtc_x, crtc_y, crtc_w, crtc_h; + struct crtc *crtc; unsigned int pipe; unsigned int i; @@ -848,14 +848,15 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) * CRTC index first, then iterate over available planes. */ for (i = 0; i (unsigned int)dev-resources-res-count_crtcs; i++) { - if (c-crtc_id == dev-resources-res-crtcs[i]) { + if (p-crtc_id == dev-resources-res-crtcs[i]) { + crtc = dev-resources-crtcs[i]; pipe = i; break; } } - if (pipe == (unsigned int)dev-resources-res-count_crtcs) { - fprintf(stderr, CRTC %u not found\n, c-crtc_id); + if (!crtc) { + fprintf(stderr, CRTC %u not found\n, p-crtc_id); return -1; } @@ -869,7 +870,8 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) } if (!plane_id) { - fprintf(stderr, no unused plane available for CRTC %u\n, c-crtc_id); + fprintf(stderr, no unused plane available for CRTC %u\n, + crtc-crtc-crtc_id); return -1; } @@ -890,8 +892,8 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) if (!p-has_position) { /* Default to the middle of the screen */ - crtc_x = (c-crtc-mode-hdisplay - p-w) / 2; - crtc_y = (c-crtc-mode-vdisplay - p-h) / 2; + crtc_x = (crtc-mode-hdisplay - p-w) / 2; + crtc_y = (crtc-mode-vdisplay - p-h) / 2; } else { crtc_x = p-x; crtc_y = p-y; @@ -900,7 +902,7 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) crtc_h = p-h; /* note src coords (last 4 args) are in Q16 format */ - if (drmModeSetPlane(dev-fd, plane_id, c-crtc_id, p-fb_id, + if (drmModeSetPlane(dev-fd, plane_id, crtc-crtc-crtc_id, p-fb_id, plane_flags, crtc_x, crtc_y, crtc_w, crtc_h, 0, 0, p-w 16, p-h 16)) { fprintf(stderr, failed to enable plane: %s\n, @@ -908,7 +910,7 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) return -1; } - ovr-crtc_id = c-crtc_id; + ovr-crtc_id = crtc-crtc-crtc_id; return 0; } @@ -969,8 +971,8 @@ static void set_mode(struct device *dev, struct connector_arg *c, int count, /* if we have a plane/overlay to show, set that up now: */ for (j = 0; j plane_count; j++) - if (p[j].con_id == c[i].id) - if (set_plane(dev, c[i], p[j])) + if (p[j].crtc_id == c[i].crtc_id) + if (set_plane(dev, p[j])) return; } @@ -1099,7 +1101,7 @@ static int parse_plane(struct plane_arg *plane, const char *p) memset(plane, 0, sizeof *plane); - plane-con_id = strtoul(p, end, 10); + plane-crtc_id = strtoul(p, end, 10); if (*end != ':') return -EINVAL; @@ -1161,7 +1163,7 @@ static void usage(char *name) fprintf(stderr, \t-p\tlist CRTCs and planes (pipes)\n); fprintf(stderr, \n Test options:\n\n); - fprintf(stderr, \t-P connector_id:wxh[+x+y][@format]\tset a plane\n); + fprintf(stderr, \t-P crtc_id:wxh[+x+y][@format]\tset a plane\n); fprintf(stderr, \t-s connector_id[@crtc_id]:mode[@format]\tset
[PATCH v6 19/23] modetest: Rename struct connector_arg to struct pipe_arg
This prepares the code for handling multiple connectors in a single pipeline in a cloned configuration. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 162 -- 1 file changed, 85 insertions(+), 77 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 93a0864..922d9b0 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -635,7 +635,7 @@ error: } /* - - * Connectors and planes + * Pipes and planes */ /* @@ -645,8 +645,8 @@ error: * Then you need to find the encoder attached to that connector so you * can bind it with a free crtc. */ -struct connector_arg { - uint32_t id; +struct pipe_arg { + uint32_t con_id; uint32_t crtc_id; char mode_str[64]; char format_str[5]; @@ -669,14 +669,14 @@ struct plane_arg { unsigned int fourcc; }; -static void connector_find_mode(struct device *dev, struct connector_arg *c) +static void pipe_find_mode(struct device *dev, struct pipe_arg *pipe) { drmModeConnector *connector; drmModeEncoder *encoder; int i, j; /* First, find the connector mode */ - c-mode = NULL; + pipe-mode = NULL; for (i = 0; i dev-resources-res-count_connectors; i++) { connector = dev-resources-connectors[i].connector; if (!connector) @@ -685,50 +685,50 @@ static void connector_find_mode(struct device *dev, struct connector_arg *c) if (!connector-count_modes) continue; - if (connector-connector_id != c-id) + if (connector-connector_id != pipe-con_id) continue; for (j = 0; j connector-count_modes; j++) { - c-mode = connector-modes[j]; - if (!strcmp(c-mode-name, c-mode_str)) + pipe-mode = connector-modes[j]; + if (!strcmp(pipe-mode-name, pipe-mode_str)) break; } /* Found it, break out */ - if (c-mode) + if (pipe-mode) break; } - if (!c-mode) { - fprintf(stderr, failed to find mode \%s\\n, c-mode_str); + if (!pipe-mode) { + fprintf(stderr, failed to find mode \%s\\n, pipe-mode_str); return; } /* If the CRTC ID was specified, get the corresponding CRTC. Otherwise * locate a CRTC that can be attached to the connector. */ - if (c-crtc_id == (uint32_t)-1) { + if (pipe-crtc_id == (uint32_t)-1) { for (i = 0; i dev-resources-res-count_encoders; i++) { encoder = dev-resources-encoders[i].encoder; if (!encoder) continue; if (encoder-encoder_id == connector-encoder_id) { - c-crtc_id = encoder-crtc_id; + pipe-crtc_id = encoder-crtc_id; break; } } } - if (c-crtc_id == (uint32_t)-1) + if (pipe-crtc_id == (uint32_t)-1) return; for (i = 0; i dev-resources-res-count_crtcs; i++) { struct crtc *crtc = dev-resources-crtcs[i]; - if (c-crtc_id == crtc-crtc-crtc_id) { - crtc-mode = c-mode; - c-crtc = crtc; + if (pipe-crtc_id == crtc-crtc-crtc_id) { + crtc-mode = pipe-mode; + pipe-crtc = crtc; break; } } @@ -815,28 +815,28 @@ static void page_flip_handler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data) { - struct connector_arg *c; + struct pipe_arg *pipe; unsigned int new_fb_id; struct timeval end; double t; - c = data; - if (c-current_fb_id == c-fb_id[0]) - new_fb_id = c-fb_id[1]; + pipe = data; + if (pipe-current_fb_id == pipe-fb_id[0]) + new_fb_id = pipe-fb_id[1]; else - new_fb_id = c-fb_id[0]; + new_fb_id = pipe-fb_id[0]; - drmModePageFlip(fd, c-crtc_id, new_fb_id, - DRM_MODE_PAGE_FLIP_EVENT, c); - c-current_fb_id = new_fb_id; - c-swap_count++; - if (c-swap_count == 60) { + drmModePageFlip(fd, pipe-crtc_id, new_fb_id, + DRM_MODE_PAGE_FLIP_EVENT, pipe); + pipe-current_fb_id = new_fb_id; + pipe-swap_count++; + if (pipe-swap_count == 60) { gettimeofday(end, NULL
[PATCH v6 20/23] modetest: Support pipes with multiple connectors
The -s argument can now take a list of connectors. Configure all of them in cloned mode using a single CRTC. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 211 ++ 1 file changed, 157 insertions(+), 54 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 922d9b0..450c86d 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -40,6 +40,7 @@ #include config.h #include assert.h +#include ctype.h #include stdbool.h #include stdio.h #include stdlib.h @@ -634,6 +635,34 @@ error: return NULL; } +static drmModeConnector *get_connector_by_id(struct device *dev, uint32_t id) +{ + drmModeConnector *connector; + int i; + + for (i = 0; i dev-resources-res-count_connectors; i++) { + connector = dev-resources-connectors[i].connector; + if (connector connector-connector_id == id) + return connector; + } + + return NULL; +} + +static drmModeEncoder *get_encoder_by_id(struct device *dev, uint32_t id) +{ + drmModeEncoder *encoder; + int i; + + for (i = 0; i dev-resources-res-count_encoders; i++) { + encoder = dev-resources-encoders[i].encoder; + if (encoder encoder-encoder_id == id) + return encoder; + } + + return NULL; +} + /* - * Pipes and planes */ @@ -646,7 +675,8 @@ error: * can bind it with a free crtc. */ struct pipe_arg { - uint32_t con_id; + uint32_t *con_ids; + unsigned int num_cons; uint32_t crtc_id; char mode_str[64]; char format_str[5]; @@ -669,69 +699,114 @@ struct plane_arg { unsigned int fourcc; }; -static void pipe_find_mode(struct device *dev, struct pipe_arg *pipe) +static drmModeModeInfo * +connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str) { drmModeConnector *connector; - drmModeEncoder *encoder; - int i, j; + drmModeModeInfo *mode; + int i; - /* First, find the connector mode */ - pipe-mode = NULL; - for (i = 0; i dev-resources-res-count_connectors; i++) { - connector = dev-resources-connectors[i].connector; + connector = get_connector_by_id(dev, con_id); + if (!connector || !connector-count_modes) + return NULL; + + for (i = 0; i connector-count_modes; i++) { + mode = connector-modes[i]; + if (!strcmp(mode-name, mode_str)) + return mode; + } + + return NULL; +} + +static struct crtc *pipe_find_crtc(struct device *dev, struct pipe_arg *pipe) +{ + uint32_t possible_crtcs = ~0; + uint32_t active_crtcs = 0; + unsigned int crtc_idx; + unsigned int i; + int j; + + for (i = 0; i pipe-num_cons; ++i) { + drmModeConnector *connector; + drmModeEncoder *encoder; + + connector = get_connector_by_id(dev, pipe-con_ids[i]); if (!connector) - continue; + return NULL; - if (!connector-count_modes) - continue; + encoder = get_encoder_by_id(dev, connector-encoder_id); + if (!encoder) + return NULL; - if (connector-connector_id != pipe-con_id) - continue; + possible_crtcs = encoder-possible_crtcs; - for (j = 0; j connector-count_modes; j++) { - pipe-mode = connector-modes[j]; - if (!strcmp(pipe-mode-name, pipe-mode_str)) + for (j = 0; j dev-resources-res-count_crtcs; ++j) { + drmModeCrtc *crtc = dev-resources-crtcs[j].crtc; + if (crtc crtc-crtc_id == encoder-crtc_id) { + active_crtcs |= 1 j; break; + } } - - /* Found it, break out */ - if (pipe-mode) - break; } - if (!pipe-mode) { - fprintf(stderr, failed to find mode \%s\\n, pipe-mode_str); - return; + if (!possible_crtcs) + return NULL; + + /* Return the first possible and active CRTC if one exists, or the first +* possible CRTC otherwise. +*/ + if (possible_crtcs active_crtcs) + crtc_idx = ffs(possible_crtcs active_crtcs); + else + crtc_idx = ffs(possible_crtcs); + + return dev-resources-crtcs[crtc_idx - 1]; +} + +static int pipe_find_crtc_and_mode(struct device *dev, struct pipe_arg *pipe) +{ + drmModeModeInfo *mode; + int i
[PATCH v6 21/23] modetest: Try all possible encoders for a connector
When building the pipeline, instead of using only the encoders attached to a connector, take all possible encoders into account to locate a CRTC. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 35 +-- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 450c86d..e49838b 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -635,6 +635,19 @@ error: return NULL; } +static int get_crtc_index(struct device *dev, uint32_t id) +{ + int i; + + for (i = 0; i dev-resources-res-count_crtcs; ++i) { + drmModeCrtc *crtc = dev-resources-crtcs[i].crtc; + if (crtc crtc-crtc_id == id) + return i; + } + + return -1; +} + static drmModeConnector *get_connector_by_id(struct device *dev, uint32_t id) { drmModeConnector *connector; @@ -728,26 +741,28 @@ static struct crtc *pipe_find_crtc(struct device *dev, struct pipe_arg *pipe) int j; for (i = 0; i pipe-num_cons; ++i) { + uint32_t crtcs_for_connector = 0; drmModeConnector *connector; drmModeEncoder *encoder; + int idx; connector = get_connector_by_id(dev, pipe-con_ids[i]); if (!connector) return NULL; - encoder = get_encoder_by_id(dev, connector-encoder_id); - if (!encoder) - return NULL; + for (j = 0; j connector-count_encoders; ++j) { + encoder = get_encoder_by_id(dev, connector-encoders[j]); + if (!encoder) + continue; - possible_crtcs = encoder-possible_crtcs; + crtcs_for_connector |= encoder-possible_crtcs; - for (j = 0; j dev-resources-res-count_crtcs; ++j) { - drmModeCrtc *crtc = dev-resources-crtcs[j].crtc; - if (crtc crtc-crtc_id == encoder-crtc_id) { - active_crtcs |= 1 j; - break; - } + idx = get_crtc_index(dev, encoder-crtc_id); + if (idx = 0) + active_crtcs |= 1 idx; } + + possible_crtcs = crtcs_for_connector; } if (!possible_crtcs) -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v6 22/23] modetest: Fix line stride in SMPTE YUV packet pattern generator
The line stride passed to the function is expressed in bytes, there's no need to multiply it by 2. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/buffers.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c index 1ca3be5..1575bf6 100644 --- a/tests/modetest/buffers.c +++ b/tests/modetest/buffers.c @@ -337,13 +337,13 @@ fill_smpte_yuv_packed(const struct yuv_info *yuv, unsigned char *mem, for (y = 0; y height * 6 / 9; ++y) { for (x = 0; x width; ++x) y_mem[2*x] = colors_top[x * 7 / width].y; - y_mem += stride * 2; + y_mem += stride; } for (; y height * 7 / 9; ++y) { for (x = 0; x width; ++x) y_mem[2*x] = colors_middle[x * 7 / width].y; - y_mem += stride * 2; + y_mem += stride; } for (; y height; ++y) { @@ -354,7 +354,7 @@ fill_smpte_yuv_packed(const struct yuv_info *yuv, unsigned char *mem, / (width / 7) + 4].y; for (; x width; ++x) y_mem[2*x] = colors_bottom[7].y; - y_mem += stride * 2; + y_mem += stride; } /* Chroma */ @@ -363,7 +363,7 @@ fill_smpte_yuv_packed(const struct yuv_info *yuv, unsigned char *mem, c_mem[2*x+u] = colors_top[x * 7 / width].u; c_mem[2*x+v] = colors_top[x * 7 / width].v; } - c_mem += stride * 2; + c_mem += stride; } for (; y height * 7 / 9; ++y) { @@ -371,7 +371,7 @@ fill_smpte_yuv_packed(const struct yuv_info *yuv, unsigned char *mem, c_mem[2*x+u] = colors_middle[x * 7 / width].u; c_mem[2*x+v] = colors_middle[x * 7 / width].v; } - c_mem += stride * 2; + c_mem += stride; } for (; y height; ++y) { @@ -389,7 +389,7 @@ fill_smpte_yuv_packed(const struct yuv_info *yuv, unsigned char *mem, c_mem[2*x+u] = colors_bottom[7].u; c_mem[2*x+v] = colors_bottom[7].v; } - c_mem += stride * 2; + c_mem += stride; } } -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v6 23/23] modetest: Allocate NV buffers large enough for the two planes
Multiple the image height by 1.5 for NV12/NV21 and by 2 for NV16/NV61 to make room for the chroma plane. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/buffers.c | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/modetest/buffers.c b/tests/modetest/buffers.c index 1575bf6..8206ce3 100644 --- a/tests/modetest/buffers.c +++ b/tests/modetest/buffers.c @@ -1038,12 +1038,29 @@ create_test_buffer(struct kms_driver *kms, unsigned int format, unsigned int handles[4], unsigned int pitches[4], unsigned int offsets[4], enum fill_pattern pattern) { + unsigned int virtual_height; struct kms_bo *bo; void *planes[3] = { 0, }; void *virtual; int ret; - bo = allocate_buffer(kms, width, height, pitches[0]); + switch (format) { + case DRM_FORMAT_NV12: + case DRM_FORMAT_NV21: + virtual_height = height * 3 / 2; + break; + + case DRM_FORMAT_NV16: + case DRM_FORMAT_NV61: + virtual_height = height * 2; + break; + + default: + virtual_height = height; + break; + } + + bo = allocate_buffer(kms, width, virtual_height, pitches[0]); if (!bo) return NULL; -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 0/3] drm/cma: use prim helpers instead GEM CMA specific dma_buf functionality
Hi Joonyoung, On Wednesday 12 June 2013 22:16:14 Joonyoung Shim wrote: Hi, GEM CMA supports dma_buf but it needs GEM CMA specific functionality for dma_buf. We can use prime helpers for dma_buf by commit 89177644a7b6306e6084a89eab7e290f4bfef397 drm: add prime helpers, so this patchset is to replace from using GEM CMA specific functions to using prime helpers. Overall this looks good to me, except the that prime helpers don't cache mappings, unlike the current implementation in the GEM CMA helpers. Could that be fixed in the prime helpers first ? Thanks. Joonyoung Shim (3): drm: add mmap function to prime helpers drm/cma: add low-level hook functions to use prime helpers drm/cma: remove GEM CMA specific dma_buf functionality drivers/gpu/drm/drm_gem_cma_helper.c | 291 --- drivers/gpu/drm/drm_prime.c | 5 +- include/drm/drmP.h | 2 + include/drm/drm_gem_cma_helper.h | 13 +- 4 files changed, 56 insertions(+), 255 deletions(-) -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 1/3] drm: add prime helpers
Hi Aaron, A bit late, but here's a small question. On Tuesday 15 January 2013 12:47:42 Aaron Plattner wrote: Instead of reimplementing all of the dma_buf functionality in every driver, create helpers drm_prime_import and drm_prime_export that implement them in terms of new, lower-level hook functions: gem_prime_pin: callback when a buffer is created, used to pin buffers into GTT gem_prime_get_sg_table: convert a drm_gem_object to an sg_table for export gem_prime_import_sg_table: convert an sg_table into a drm_gem_object gem_prime_vmap, gem_prime_vunmap: map and unmap an object These hooks are optional; drivers can opt in by using drm_gem_prime_import and drm_gem_prime_export as the .gem_prime_import and .gem_prime_export fields of struct drm_driver. v2: - Drop .begin_cpu_access. None of the drivers this code replaces implemented it. Having it here was a leftover from when I was trying to include i915 in this rework. - Use mutex_lock instead of mutex_lock_interruptible, as these three drivers did. This patch series shouldn't change that behavior. - Rename helpers to gem_prime_get_sg_table and gem_prime_import_sg_table. Rename struct sg_table* variables to 'sgt' for clarity. - Update drm.tmpl for these new hooks. v3: - Pass the vaddr down to the driver. This lets drivers that just call vunmap on the pointer avoid having to store the pointer in their GEM private structures. - Move documentation into a /** DOC */ comment in drm_prime.c and include it in drm.tmpl with a !P line. I tried to use !F lines to include documentation of the individual functions from drmP.h, but the docproc / kernel-doc scripts barf on that file, so hopefully this is good enough for now. - apply refcount fix from commit be8a42ae60addd8b6092535c11b42d099d6470ec (drm/prime: drop reference on imported dma-buf come from gem) Signed-off-by: Aaron Plattner aplatt...@nvidia.com Cc: Daniel Vetter daniel.vet...@ffwll.ch Cc: David Airlie airl...@linux.ie --- Documentation/DocBook/drm.tmpl | 4 + drivers/gpu/drm/drm_prime.c| 186 +- include/drm/drmP.h | 12 +++ 3 files changed, 201 insertions(+), 1 deletion(-) [snip] diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 7f12573..366910d 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c [snip] +/** + * DOC: PRIME Helpers + * + * Drivers can implement @gem_prime_export and @gem_prime_import in terms of + * simpler APIs by using the helper functions @drm_gem_prime_export and + * @drm_gem_prime_import. These functions implement dma-buf support in terms of + * five lower-level driver callbacks: + * + * Export callbacks: + * + * - @gem_prime_pin (optional): prepare a GEM object for exporting + * + * - @gem_prime_get_sg_table: provide a scatter/gather table of pinned pages + * + * - @gem_prime_vmap: vmap a buffer exported by your driver + * + * - @gem_prime_vunmap: vunmap a buffer exported by your driver + * + * Import callback: + * + * - @gem_prime_import_sg_table (import): produce a GEM object from another + *driver's scatter/gather table + */ + +struct dma_buf *drm_gem_prime_export(struct drm_device *dev, + struct drm_gem_object *obj, int flags) +{ + if (dev-driver-gem_prime_pin) { + int ret = dev-driver-gem_prime_pin(obj); + if (ret) + return ERR_PTR(ret); + } + return dma_buf_export(obj, drm_gem_prime_dmabuf_ops, obj-size, + 0600); Why do you use 0600 instead of the flags passed by the caller ? +} +EXPORT_SYMBOL(drm_gem_prime_export); -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 1/3] drm: add prime helpers
Hi Aaron, On Tuesday 18 June 2013 16:28:15 Aaron Plattner wrote: On 06/18/2013 04:08 PM, Laurent Pinchart wrote: Hi Aaron, A bit late, but here's a small question. On Tuesday 15 January 2013 12:47:42 Aaron Plattner wrote: Instead of reimplementing all of the dma_buf functionality in every driver, create helpers drm_prime_import and drm_prime_export that implement them in terms of new, lower-level hook functions: gem_prime_pin: callback when a buffer is created, used to pin buffers into GTT gem_prime_get_sg_table: convert a drm_gem_object to an sg_table for export gem_prime_import_sg_table: convert an sg_table into a drm_gem_object gem_prime_vmap, gem_prime_vunmap: map and unmap an object These hooks are optional; drivers can opt in by using drm_gem_prime_import and drm_gem_prime_export as the .gem_prime_import and .gem_prime_export fields of struct drm_driver. v2: - Drop .begin_cpu_access. None of the drivers this code replaces implemented it. Having it here was a leftover from when I was trying to include i915 in this rework. - Use mutex_lock instead of mutex_lock_interruptible, as these three drivers did. This patch series shouldn't change that behavior. - Rename helpers to gem_prime_get_sg_table and gem_prime_import_sg_table. Rename struct sg_table* variables to 'sgt' for clarity. - Update drm.tmpl for these new hooks. v3: - Pass the vaddr down to the driver. This lets drivers that just call vunmap on the pointer avoid having to store the pointer in their GEM private structures. - Move documentation into a /** DOC */ comment in drm_prime.c and include it in drm.tmpl with a !P line. I tried to use !F lines to include documentation of the individual functions from drmP.h, but the docproc / kernel-doc scripts barf on that file, so hopefully this is good enough for now. - apply refcount fix from commit be8a42ae60addd8b6092535c11b42d099d6470ec (drm/prime: drop reference on imported dma-buf come from gem) Signed-off-by: Aaron Plattner aplatt...@nvidia.com Cc: Daniel Vetter daniel.vet...@ffwll.ch Cc: David Airlie airl...@linux.ie --- Documentation/DocBook/drm.tmpl | 4 + drivers/gpu/drm/drm_prime.c| 186 +- include/drm/drmP.h | 12 +++ 3 files changed, 201 insertions(+), 1 deletion(-) [snip] diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 7f12573..366910d 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c [snip] +/** + * DOC: PRIME Helpers + * + * Drivers can implement @gem_prime_export and @gem_prime_import in terms of + * simpler APIs by using the helper functions @drm_gem_prime_export and + * @drm_gem_prime_import. These functions implement dma-buf support in terms of + * five lower-level driver callbacks: + * + * Export callbacks: + * + * - @gem_prime_pin (optional): prepare a GEM object for exporting + * + * - @gem_prime_get_sg_table: provide a scatter/gather table of pinned pages + * + * - @gem_prime_vmap: vmap a buffer exported by your driver + * + * - @gem_prime_vunmap: vunmap a buffer exported by your driver + * + * Import callback: + * + * - @gem_prime_import_sg_table (import): produce a GEM object from another + *driver's scatter/gather table + */ + +struct dma_buf *drm_gem_prime_export(struct drm_device *dev, + struct drm_gem_object *obj, int flags) +{ + if (dev-driver-gem_prime_pin) { + int ret = dev-driver-gem_prime_pin(obj); + if (ret) + return ERR_PTR(ret); + } + return dma_buf_export(obj, drm_gem_prime_dmabuf_ops, obj-size, +0600); Why do you use 0600 instead of the flags passed by the caller ? Because I copied pasted it from i915_gem_prime_export prior to commit 5b42427fc38ecb9056c4e64deaff36d6d6ba1b67 and didn't notice until you pointed it out just now. That's a pretty valid reason I guess :-) Should I submit a patch or are you already working on one ? +} +EXPORT_SYMBOL(drm_gem_prime_export); -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3] drm: Renesas R-Car Display Unit DRM driver
Hello Adam, Ping ? Daniel, would it help getting the driver in v3.11 if I resubmit it now with a get_modes operation that just returns 0 ? On Friday 14 June 2013 16:03:19 Daniel Vetter wrote: On Fri, Jun 14, 2013 at 02:54:04AM +0200, Laurent Pinchart wrote: On Friday 07 June 2013 10:50:55 Daniel Vetter wrote: On Fri, Jun 07, 2013 at 09:44:45AM +0200, Laurent Pinchart wrote: On Wednesday 05 June 2013 10:55:05 Daniel Vetter wrote: On Wed, Jun 05, 2013 at 03:51:53AM +0200, Laurent Pinchart wrote: On Tuesday 04 June 2013 20:36:20 Daniel Vetter wrote: On Tue, Jun 4, 2013 at 8:03 PM, Laurent Pinchart wrote: On Tuesday 04 June 2013 16:12:36 Daniel Vetter wrote: On Tue, Jun 04, 2013 at 04:53:40AM +0200, Laurent Pinchart wrote: [snip] +static int rcar_du_vga_connector_get_modes(struct drm_connector *connector) +{ + return drm_add_modes_noedid(connector, 1280, 768); +} This (and the dummy detect function below) looks a bit funny, since it essentially overrides the default behaviour already provided by the crtc helpers. Until rcar has at least proper detect support for VGA I would add that but the DDC signals are not connected on the boards I have access to :-/ I'd just kill this and use the connector force support (and manually adding the right resolutions). Looks like that's a candidate for better documentation... How does force support work ? Grep for DRM_FORCE_ON, iirc it can be set on the commandline, where you can also force a specific mode. The best I could find wrt docs is the kerneldoc for drm_mode_parse_command_line_for_connector. With a bit more reading it looks like it's intermingled with the fbdev helper code, but should be fairly easy to extract and used by your driver. It makes sense to force the connector state from command line, but I'm not sure if the same mechanism is the best solution here. As the driver has no way to know the connector state, the best we can do is guess what modes are supported. I can just return 0 in the get_modes handler, but then the core will not call drm_add_modes_noedid(), and modes will need to be added manually. Is your point that for a board on which the VGA connector state can't be detected, the user should always be responsible for adding all the modes supported by the VGA monitor on the command line ? My point is that we already have both an established code for connected outputs without EDID to add fallback modes and means to force connectors to certain states. Your code here seems to reinvent that wheel, so I wonder what we should/need to improve in the common code to suit your needs. The currently available code might suit my needs, it might just be that I fail to see how to use it properly. Regarding the code for connected outputs without EDID to add fallback modes you're referring to, is that if (count == 0 connector-status == connector_status_connected) count = drm_add_modes_noedid(connector, 1024, 768); in drm_helper_probe_single_connector_modes() ? That function will only be called if the connector status is connector_status_connected. There are two ways to enforce that: - returning connector_status_connected from the connector detect() operation, which seems to defeat the purpose of having connector_status_unknown completely. We might want to add such a default mode also for unknown, I'm not sure. Userspace policy is to first try to light up any connected outputs, and if there's none try to light up any unknown outputs. Not sure whether userspace (i.e. X) will automatically add a default mode. fbcon might also handle this less gracefully. Personally I'm ok with extending this to unknown, it shouldn't really hurt (since we already try really hard not to leak unknown anywhere visible). Do you mean something like diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index f554516..9aae384 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c @@ -160,7 +160,8 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector, #endif count = (*connector_funcs-get_modes)(connector); - if (count == 0 connector-status == connector_status_connected) + if (count == 0 (connector-status == connector_status_connected || + connector-status == connector_status_unknown)) count = drm_add_modes_noedid(connector, 1024, 768); if (count == 0) goto prune; If so I can submit
Re: [PATCH 4/4] drm: Constify the pretty-print functions
const struct drm_prop_enum_list drm_dirty_info_enum_list[] = { { DRM_MODE_DIRTY_OFF, Off }, { DRM_MODE_DIRTY_ON, On }, { DRM_MODE_DIRTY_ANNOTATE, Annotate }, @@ -185,7 +185,7 @@ static struct drm_prop_enum_list drm_dirty_info_enum_list[] = { struct drm_conn_prop_enum_list { int type; - char *name; + const char *name; int count; }; @@ -211,7 +211,7 @@ static struct drm_conn_prop_enum_list drm_connector_enum_list[] = { DRM_MODE_CONNECTOR_VIRTUAL, Virtual, 0}, }; -static struct drm_prop_enum_list drm_encoder_enum_list[] = +static const struct drm_prop_enum_list drm_encoder_enum_list[] = {{ DRM_MODE_ENCODER_NONE, None }, { DRM_MODE_ENCODER_DAC, DAC }, { DRM_MODE_ENCODER_TMDS, TMDS }, @@ -220,7 +220,7 @@ static struct drm_prop_enum_list drm_encoder_enum_list[] = { DRM_MODE_ENCODER_VIRTUAL, Virtual }, }; -char *drm_get_encoder_name(struct drm_encoder *encoder) +const char *drm_get_encoder_name(const struct drm_encoder *encoder) { static char buf[32]; @@ -231,7 +231,7 @@ char *drm_get_encoder_name(struct drm_encoder *encoder) } EXPORT_SYMBOL(drm_get_encoder_name); -char *drm_get_connector_name(struct drm_connector *connector) +const char *drm_get_connector_name(const struct drm_connector *connector) { static char buf[32]; @@ -242,7 +242,7 @@ char *drm_get_connector_name(struct drm_connector *connector) } EXPORT_SYMBOL(drm_get_connector_name); -char *drm_get_connector_status_name(enum drm_connector_status status) +const char *drm_get_connector_status_name(enum drm_connector_status status) { if (status == connector_status_connected) return connected; @@ -258,7 +258,7 @@ static char printable_char(int c) return isascii(c) isprint(c) ? c : '?'; } -char *drm_get_format_name(uint32_t format) +const char *drm_get_format_name(uint32_t format) { static char buf[32]; diff --git a/include/drm/drmP.h b/include/drm/drmP.h index b06f5af..e931a65 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -1598,7 +1598,6 @@ extern void drm_sysfs_destroy(void); extern int drm_sysfs_device_add(struct drm_minor *minor); extern void drm_sysfs_hotplug_event(struct drm_device *dev); extern void drm_sysfs_device_remove(struct drm_minor *minor); -extern char *drm_get_connector_status_name(enum drm_connector_status status); extern int drm_sysfs_connector_add(struct drm_connector *connector); extern void drm_sysfs_connector_remove(struct drm_connector *connector); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 2cbbfd4..53c33e2 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -897,12 +897,13 @@ extern void drm_plane_cleanup(struct drm_plane *plane); extern void drm_encoder_cleanup(struct drm_encoder *encoder); -extern char *drm_get_connector_name(struct drm_connector *connector); -extern char *drm_get_dpms_name(int val); -extern char *drm_get_dvi_i_subconnector_name(int val); -extern char *drm_get_dvi_i_select_name(int val); -extern char *drm_get_tv_subconnector_name(int val); -extern char *drm_get_tv_select_name(int val); +extern const char *drm_get_connector_name(const struct drm_connector *connector); +extern const char *drm_get_connector_status_name(enum drm_connector_status status); +extern const char *drm_get_dpms_name(int val); +extern const char *drm_get_dvi_i_subconnector_name(int val); +extern const char *drm_get_dvi_i_select_name(int val); +extern const char *drm_get_tv_subconnector_name(int val); +extern const char *drm_get_tv_select_name(int val); extern void drm_fb_release(struct drm_file *file_priv); extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group); extern bool drm_probe_ddc(struct i2c_adapter *adapter); @@ -994,7 +995,7 @@ extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats extern int drm_mode_create_scaling_mode_property(struct drm_device *dev); extern int drm_mode_create_dithering_property(struct drm_device *dev); extern int drm_mode_create_dirty_info_property(struct drm_device *dev); -extern char *drm_get_encoder_name(struct drm_encoder *encoder); +extern const char *drm_get_encoder_name(const struct drm_encoder *encoder); extern int drm_mode_connector_attach_encoder(struct drm_connector *connector, struct drm_encoder *encoder); @@ -1094,6 +1095,6 @@ extern int drm_format_num_planes(uint32_t format); extern int drm_format_plane_cpp(uint32_t format, int plane); extern int drm_format_horz_chroma_subsampling(uint32_t format); extern int drm_format_vert_chroma_subsampling(uint32_t format); -extern char *drm_get_format_name(uint32_t format); +extern const char *drm_get_format_name(uint32_t format); #endif /* __DRM_CRTC_H__ */ -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel
Re: [PATCH v2] drm: Remove some unused stuff from drm_plane
Hello, On Wednesday 08 May 2013 15:52:10 Laurent Pinchart wrote: On Wednesday 08 May 2013 16:40:54 ville.syrj...@linux.intel.com wrote: From: Ville Syrjälä ville.syrj...@linux.intel.com There's a bunch of unused members inside drm_plane, bloating the size of the structure needlessly. Eliminate them. v2: Remove all of it from kernel-doc too Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com Reviewed-by: Laurent Pinchart laurent.pinch...@ideasonboard.com Wow, I've managed to review the patch and miss that it broke compilation of the shmob-drm driver :-( I'll send a patch to fix it. --- drivers/gpu/drm/drm_crtc.c | 2 +- include/drm/drm_crtc.h | 11 --- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index d7c449f..e591914 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1739,7 +1739,7 @@ int drm_mode_getplane(struct drm_device *dev, void *data, plane_resp-plane_id = plane-base.id; plane_resp-possible_crtcs = plane-possible_crtcs; - plane_resp-gamma_size = plane-gamma_size; + plane_resp-gamma_size = 0; /* * This ioctl is called twice, once to determine how much space is diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index adb3f9b..e11c6bc 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -654,11 +654,7 @@ struct drm_plane_funcs { * @format_count: number of formats supported * @crtc: currently bound CRTC * @fb: currently bound fb - * @gamma_size: size of gamma table - * @gamma_store: gamma correction table - * @enabled: enabled flag * @funcs: helper functions - * @helper_private: storage for drver layer * @properties: property tracking for this plane */ struct drm_plane { @@ -674,14 +670,7 @@ struct drm_plane { struct drm_crtc *crtc; struct drm_framebuffer *fb; - /* CRTC gamma size for reporting to userspace */ - uint32_t gamma_size; - uint16_t *gamma_store; - - bool enabled; - const struct drm_plane_funcs *funcs; - void *helper_private; struct drm_object_properties properties; }; -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/prime: Honor requested file flags when exporting a buffer
The DRM PRIME API passes file flags to the driver for the exported buffer. Honor them instead of hardcoding 0600. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/drm_prime.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index d92853e..e57c675 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -210,8 +210,7 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops = { struct dma_buf *drm_gem_prime_export(struct drm_device *dev, struct drm_gem_object *obj, int flags) { - return dma_buf_export(obj, drm_gem_prime_dmabuf_ops, obj-size, -0600); + return dma_buf_export(obj, drm_gem_prime_dmabuf_ops, obj-size, flags); } EXPORT_SYMBOL(drm_gem_prime_export); -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/shmobile: Enable compilation on all ARM platforms
This is required to support multi-arch kernels. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/shmobile/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/shmobile/Kconfig b/drivers/gpu/drm/shmobile/Kconfig index 7e7d52b..62905b4 100644 --- a/drivers/gpu/drm/shmobile/Kconfig +++ b/drivers/gpu/drm/shmobile/Kconfig @@ -1,6 +1,6 @@ config DRM_SHMOBILE tristate DRM Support for SH Mobile - depends on DRM (SUPERH || ARCH_SHMOBILE) + depends on DRM (ARM || SUPERH) select DRM_KMS_HELPER select DRM_KMS_CMA_HELPER select DRM_GEM_CMA_HELPER -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm: Improve manual IRQ installation documentation
Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- Documentation/DocBook/drm.tmpl | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index f9df3b8..738b727 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -186,11 +186,12 @@ varlistentry termDRIVER_HAVE_IRQ/termtermDRIVER_IRQ_SHARED/term listitempara - DRIVER_HAVE_IRQ indicates whether the driver has an IRQ handler. The - DRM core will automatically register an interrupt handler when the - flag is set. DRIVER_IRQ_SHARED indicates whether the device amp; - handler support shared IRQs (note that this is required of PCI - drivers). + DRIVER_HAVE_IRQ indicates whether the driver has an IRQ handler + managed by the DRM Core. The core will support simple IRQ handler + installation when the flag is set. The installation process is + described in xref linkend=drm-irq-registration/./para + paraDRIVER_IRQ_SHARED indicates whether the device amp; handler + support shared IRQs (note that this is required of PCI drivers). /para/listitem /varlistentry varlistentry @@ -344,7 +345,8 @@ char *date;/synopsis The DRM core tries to facilitate IRQ handler registration and unregistration by providing functiondrm_irq_install/function and functiondrm_irq_uninstall/function functions. Those functions only - support a single interrupt per device. + support a single interrupt per device, devices that use more than one + IRQs need to be handled manually. /para !--!Fdrivers/char/drm/drm_irq.c drm_irq_install-- para -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/shmobile: Drop usage of removed drm_plane enabled field
The enabled field has been removed from struct drm_plane. Don't use it in the driver. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/shmobile/shmob_drm_plane.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) This fixes a compilation error in drm-next. I will send a pull request for the shmob-drm patches by the end of the week. diff --git a/drivers/gpu/drm/shmobile/shmob_drm_plane.c b/drivers/gpu/drm/shmobile/shmob_drm_plane.c index 6898f6f..060ae03 100644 --- a/drivers/gpu/drm/shmobile/shmob_drm_plane.c +++ b/drivers/gpu/drm/shmobile/shmob_drm_plane.c @@ -166,7 +166,7 @@ void shmob_drm_plane_setup(struct drm_plane *plane) { struct shmob_drm_plane *splane = to_shmob_plane(plane); - if (plane-fb == NULL || !plane-enabled) + if (plane-fb == NULL) return; __shmob_drm_plane_setup(splane, plane-fb); -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm: Improve manual IRQ installation documentation
Hi Thierry, On Thursday 20 June 2013 12:10:47 Thierry Reding wrote: On Wed, Jun 19, 2013 at 02:00:45PM +0200, Laurent Pinchart wrote: Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- Documentation/DocBook/drm.tmpl | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index f9df3b8..738b727 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -186,11 +186,12 @@ varlistentry termDRIVER_HAVE_IRQ/termtermDRIVER_IRQ_SHARED/term listitempara - DRIVER_HAVE_IRQ indicates whether the driver has an IRQ handler. The - DRM core will automatically register an interrupt handler when the - flag is set. DRIVER_IRQ_SHARED indicates whether the device amp; - handler support shared IRQs (note that this is required of PCI - drivers). + DRIVER_HAVE_IRQ indicates whether the driver has an IRQ handler + managed by the DRM Core. The core will support simple IRQ handler + installation when the flag is set. The installation process is + described in xref linkend=drm-irq-registration/./para + paraDRIVER_IRQ_SHARED indicates whether the device amp; handler + support shared IRQs (note that this is required of PCI drivers). /para/listitem /varlistentry varlistentry @@ -344,7 +345,8 @@ char *date;/synopsis The DRM core tries to facilitate IRQ handler registration and unregistration by providing functiondrm_irq_install/function and functiondrm_irq_uninstall/function functions. Those functions only - support a single interrupt per device. + support a single interrupt per device, devices that use more than one + IRQs need to be handled manually. Perhaps this should mention that if you handle IRQ installation manually you also need to manually set drm-irq_enabled = 1, as otherwise things like DRM_IOCTL_WAIT_VBLANK won't work properly. That's only needed if DRIVER_HAVE_IRQ is set, otherwise the drm_wait_vblank() function skips the irq_enabled check. -- Regards, Laurent Pinchart signature.asc Description: This is a digitally signed message part. ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[GIT PULL FOR v3.11] shmob-drm patches
Hi Dave, Could you please pull the following four shmob-drm patches for v3.11 ? The following changes since commit dc28aa072f502433b6adc5c9ae8f56955c07580a: gpu:drm:tilcdc: get preferred_bpp value from DT (2013-06-20 14:08:01 +1000) are available in the git repository at: git://linuxtv.org/pinchartl/fbdev.git drm/shmob for you to fetch changes up to 227c1fb28c7d01ccbd9203e42734c06b470d1744: drm/shmobile: Enable compilation on all ARM platforms (2013-06-20 10:07:14 +0200) Laurent Pinchart (4): drm/shmobile: Minor typo fix in debug message drm/shmobile: Use devm_* managed functions drm/shmobile: Add DRM PRIME support drm/shmobile: Enable compilation on all ARM platforms drivers/gpu/drm/shmobile/Kconfig | 2 +- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 35 + drivers/gpu/drm/shmobile/shmob_drm_kms.c | 2 +- drivers/gpu/drm/shmobile/shmob_drm_plane.c | 7 +-- 4 files changed, 18 insertions(+), 28 deletions(-) -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm: Improve manual IRQ installation documentation
Hi Thierry, On Thursday 20 June 2013 12:40:26 Thierry Reding wrote: On Thu, Jun 20, 2013 at 12:17:25PM +0200, Laurent Pinchart wrote: On Thursday 20 June 2013 12:10:47 Thierry Reding wrote: On Wed, Jun 19, 2013 at 02:00:45PM +0200, Laurent Pinchart wrote: Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- Documentation/DocBook/drm.tmpl | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index f9df3b8..738b727 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -186,11 +186,12 @@ varlistentry termDRIVER_HAVE_IRQ/termtermDRIVER_IRQ_SHARED/term listitempara - DRIVER_HAVE_IRQ indicates whether the driver has an IRQ handler. The - DRM core will automatically register an interrupt handler when the - flag is set. DRIVER_IRQ_SHARED indicates whether the device amp; - handler support shared IRQs (note that this is required of PCI - drivers). + DRIVER_HAVE_IRQ indicates whether the driver has an IRQ handler + managed by the DRM Core. The core will support simple IRQ handler + installation when the flag is set. The installation process is + described in xref linkend=drm-irq-registration/./para + paraDRIVER_IRQ_SHARED indicates whether the device amp; handler + support shared IRQs (note that this is required of PCI drivers). /para/listitem /varlistentry varlistentry @@ -344,7 +345,8 @@ char *date;/synopsis The DRM core tries to facilitate IRQ handler registration and unregistration by providing functiondrm_irq_install/function and functiondrm_irq_uninstall/function functions. Those functions only - support a single interrupt per device. + support a single interrupt per device, devices that use more than one + IRQs need to be handled manually. Perhaps this should mention that if you handle IRQ installation manually you also need to manually set drm-irq_enabled = 1, as otherwise things like DRM_IOCTL_WAIT_VBLANK won't work properly. That's only needed if DRIVER_HAVE_IRQ is set, otherwise the drm_wait_vblank() function skips the irq_enabled check. Not quite. There's another check for dev-irq_enabled in the DRM_WAIT_ON() so it'll never actually block. Indeed. Arguably this could be solved by making the DRM_WAIT_ON() condition drop the !dev-irq_enabled in case DRIVER_HAVE_IRQ isn't set. Or we could force drivers to set drm-irq_enabled, I'm fine with that as well. I can fix the documentation if that would be the preferred solution. I'll see if I can find the time to come up with a patch. -- Regards, Laurent Pinchart signature.asc Description: This is a digitally signed message part. ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2] drm: Improve manual IRQ installation documentation
Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- Documentation/DocBook/drm.tmpl | 118 - 1 file changed, 70 insertions(+), 48 deletions(-) Changes since v1: - Document manual IRQ registration diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 91ee107..a608094 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -186,11 +186,12 @@ varlistentry termDRIVER_HAVE_IRQ/termtermDRIVER_IRQ_SHARED/term listitempara - DRIVER_HAVE_IRQ indicates whether the driver has an IRQ handler. The - DRM core will automatically register an interrupt handler when the - flag is set. DRIVER_IRQ_SHARED indicates whether the device amp; - handler support shared IRQs (note that this is required of PCI - drivers). + DRIVER_HAVE_IRQ indicates whether the driver has an IRQ handler + managed by the DRM Core. The core will support simple IRQ handler + installation when the flag is set. The installation process is + described in xref linkend=drm-irq-registration/./para + paraDRIVER_IRQ_SHARED indicates whether the device amp; handler + support shared IRQs (note that this is required of PCI drivers). /para/listitem /varlistentry varlistentry @@ -344,50 +345,71 @@ char *date;/synopsis The DRM core tries to facilitate IRQ handler registration and unregistration by providing functiondrm_irq_install/function and functiondrm_irq_uninstall/function functions. Those functions only - support a single interrupt per device. -/para - !--!Fdrivers/char/drm/drm_irq.c drm_irq_install-- -para - Both functions get the device IRQ by calling - functiondrm_dev_to_irq/function. This inline function will call a - bus-specific operation to retrieve the IRQ number. For platform devices, - functionplatform_get_irq/function(..., 0) is used to retrieve the - IRQ number. -/para -para - functiondrm_irq_install/function starts by calling the - methodnameirq_preinstall/methodname driver operation. The operation - is optional and must make sure that the interrupt will not get fired by - clearing all pending interrupt flags or disabling the interrupt. -/para -para - The IRQ will then be requested by a call to - functionrequest_irq/function. If the DRIVER_IRQ_SHARED driver - feature flag is set, a shared (IRQF_SHARED) IRQ handler will be - requested. -/para -para - The IRQ handler function must be provided as the mandatory irq_handler - driver operation. It will get passed directly to - functionrequest_irq/function and thus has the same prototype as all - IRQ handlers. It will get called with a pointer to the DRM device as the - second argument. -/para -para - Finally the function calls the optional - methodnameirq_postinstall/methodname driver operation. The operation - usually enables interrupts (excluding the vblank interrupt, which is - enabled separately), but drivers may choose to enable/disable interrupts - at a different time. -/para -para - functiondrm_irq_uninstall/function is similarly used to uninstall an - IRQ handler. It starts by waking up all processes waiting on a vblank - interrupt to make sure they don't hang, and then calls the optional - methodnameirq_uninstall/methodname driver operation. The operation - must disable all hardware interrupts. Finally the function frees the IRQ - by calling functionfree_irq/function. + support a single interrupt per device, devices that use more than one + IRQs need to be handled manually. /para +sect4 + titleManaged IRQ Registration/title + para +Both the functiondrm_irq_install/function and + functiondrm_irq_uninstall/function functions get the device IRQ by + calling functiondrm_dev_to_irq/function. This inline function will + call a bus-specific operation to retrieve the IRQ number. For platform + devices, functionplatform_get_irq/function(..., 0) is used to + retrieve the IRQ number. + /para + para +functiondrm_irq_install/function starts by calling the +methodnameirq_preinstall/methodname driver operation. The operation +is optional and must make sure that the interrupt will not get fired by +clearing all pending interrupt flags or disabling the interrupt. + /para
[PATCH 0/2] Documentation improvements
Hello, Here are two patches that improve the DRM documentation by documenting the KMS property API, and removing an outdated note about the i915 driver. Laurent Pinchart (2): drm/doc: Remove outdated note about i915 driver not behaving properly drm/doc: Document the KMS property API Documentation/DocBook/drm.tmpl | 147 +++-- 1 file changed, 143 insertions(+), 4 deletions(-) -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 1/2] drm/doc: Remove outdated note about i915 driver not behaving properly
From: Laurent Pinchart laurent.pinch...@ideasonboard.com The i915 driver has been fixed not to modify the mode argument of the encoder mode_fixup operation. Remove the related comment from the documentation. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- Documentation/DocBook/drm.tmpl | 4 1 file changed, 4 deletions(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index a608094..cea420d 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -1868,10 +1868,6 @@ void intel_crt_init(struct drm_device *dev) synopsisbool (*mode_fixup)(struct drm_encoder *encoder, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode);/synopsis - notepara -FIXME: The mode argument be const, but the i915 driver modifies -mode-gt;clock in functionintel_dp_mode_fixup/function. - /para/note para Let encoders adjust the requested mode or reject it completely. This operation returns true if the mode is accepted (possibly after being -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 2/2] drm/doc: Document the KMS property API
Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- Documentation/DocBook/drm.tmpl | 143 + 1 file changed, 143 insertions(+) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index cea420d..9d4bb06 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -1236,6 +1236,15 @@ int max_width, max_height;/synopsis titleMiscellaneous/title itemizedlist listitem + synopsisvoid (*set_property)(struct drm_crtc *crtc, + struct drm_property *property, uint64_t value);/synopsis + para +Set the value of the given CRTC property to +parametervalue/parameter. See xref linkend=drm-kms-properties/ +for more information about properties. + /para +/listitem +listitem synopsisvoid (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start, uint32_t size);/synopsis para @@ -1385,6 +1394,15 @@ int max_width, max_height;/synopsis xref linkend=drm-kms-init/. /para /listitem + listitem +synopsisvoid (*set_property)(struct drm_plane *plane, + struct drm_property *property, uint64_t value);/synopsis +para + Set the value of the given plane property to + parametervalue/parameter. See xref linkend=drm-kms-properties/ + for more information about properties. +/para + /listitem /itemizedlist /sect3 /sect2 @@ -1594,6 +1612,15 @@ int max_width, max_height;/synopsis titleMiscellaneous/title itemizedlist listitem + synopsisvoid (*set_property)(struct drm_connector *connector, + struct drm_property *property, uint64_t value);/synopsis + para +Set the value of the given connector property to +parametervalue/parameter. See xref linkend=drm-kms-properties/ +for more information about properties. + /para +/listitem +listitem synopsisvoid (*destroy)(struct drm_connector *connector);/synopsis para Destroy the connector when not needed anymore. See @@ -2187,6 +2214,122 @@ void intel_crt_init(struct drm_device *dev) /sect2 /sect1 + !-- Internals: kms properties -- + + sect1 id=drm-kms-properties +titleKMS Properties/title +para + Drivers may need to expose additional parameters to applications than + those described in the previous sections. KMS supports attaching + properties to CRTCs, connectors and planes and offers a userspace API to + list, get and set the property values. +/para +para + Properties are identified by a name that uniquely defines the property + purpose, and store an associated value. For all property types except blob + properties the value is a 64-bit unsigned integer. +/para +para + KMS differentiates between properties and property instances. Drivers + first create properties and then create and associate individual instances + of those properties to objects. A property can be instantiated multiple + times and associated with different objects. Values are stored in property + instances, and all other property information are stored in the propery + and shared between all instances of the property. +/para +para + Every property is created with a type that influences how the KMS core + handles the property. Supported property types are + variablelist +varlistentry + termDRM_MODE_PROP_RANGE/term + listitemparaRanges properties report their minimum and maximum +admissible values. The KMS core verifies that values set by +application fit in that range./para/listitem +/varlistentry +varlistentry + termDRM_MODE_PROP_ENUM/term + listitemparaEnumerated properties take a numerical value that +ranges from 0 to the number of enumered values defined by the +property minus one, and associate a free-formed string name to each +value. Application can retrieve the list of define value-name pairs +and use the numerical value to get and set property instance values. +/para/listitem +/varlistentry +varlistentry + termDRM_MODE_PROP_BITMASK/term + listitemparaBitmask properties are enumeration properties that +additionally restrict all enumerated values to the 0..63 range. +Bitmask property instance values combine one or more of the +enumerated bits defined by the property
[PATCH v2 0/2] Documentation improvements
Hello, Here are two patches that improve the DRM documentation by documenting the KMS property API, and removing an outdated note about the i915 driver. Changes since v1: - Fixed typos in patch 2/2 Laurent Pinchart (2): drm/doc: Remove outdated note about i915 driver not behaving properly drm/doc: Document the KMS property API Documentation/DocBook/drm.tmpl | 147 +++-- 1 file changed, 143 insertions(+), 4 deletions(-) -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 1/2] drm/doc: Remove outdated note about i915 driver not behaving properly
From: Laurent Pinchart laurent.pinch...@ideasonboard.com The i915 driver has been fixed not to modify the mode argument of the encoder mode_fixup operation. Remove the related comment from the documentation. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com Reviewed-by: Alex Deucher alexander.deuc...@amd.com --- Documentation/DocBook/drm.tmpl | 4 1 file changed, 4 deletions(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index a608094..cea420d 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -1868,10 +1868,6 @@ void intel_crt_init(struct drm_device *dev) synopsisbool (*mode_fixup)(struct drm_encoder *encoder, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode);/synopsis - notepara -FIXME: The mode argument be const, but the i915 driver modifies -mode-gt;clock in functionintel_dp_mode_fixup/function. - /para/note para Let encoders adjust the requested mode or reject it completely. This operation returns true if the mode is accepted (possibly after being -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 2/2] drm/doc: Document the KMS property API
Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com Reviewed-by: Alex Deucher alexander.deuc...@amd.com --- Documentation/DocBook/drm.tmpl | 143 + 1 file changed, 143 insertions(+) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index cea420d..4d54ac8 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -1236,6 +1236,15 @@ int max_width, max_height;/synopsis titleMiscellaneous/title itemizedlist listitem + synopsisvoid (*set_property)(struct drm_crtc *crtc, + struct drm_property *property, uint64_t value);/synopsis + para +Set the value of the given CRTC property to +parametervalue/parameter. See xref linkend=drm-kms-properties/ +for more information about properties. + /para +/listitem +listitem synopsisvoid (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start, uint32_t size);/synopsis para @@ -1385,6 +1394,15 @@ int max_width, max_height;/synopsis xref linkend=drm-kms-init/. /para /listitem + listitem +synopsisvoid (*set_property)(struct drm_plane *plane, + struct drm_property *property, uint64_t value);/synopsis +para + Set the value of the given plane property to + parametervalue/parameter. See xref linkend=drm-kms-properties/ + for more information about properties. +/para + /listitem /itemizedlist /sect3 /sect2 @@ -1594,6 +1612,15 @@ int max_width, max_height;/synopsis titleMiscellaneous/title itemizedlist listitem + synopsisvoid (*set_property)(struct drm_connector *connector, + struct drm_property *property, uint64_t value);/synopsis + para +Set the value of the given connector property to +parametervalue/parameter. See xref linkend=drm-kms-properties/ +for more information about properties. + /para +/listitem +listitem synopsisvoid (*destroy)(struct drm_connector *connector);/synopsis para Destroy the connector when not needed anymore. See @@ -2187,6 +2214,122 @@ void intel_crt_init(struct drm_device *dev) /sect2 /sect1 + !-- Internals: kms properties -- + + sect1 id=drm-kms-properties +titleKMS Properties/title +para + Drivers may need to expose additional parameters to applications than + those described in the previous sections. KMS supports attaching + properties to CRTCs, connectors and planes and offers a userspace API to + list, get and set the property values. +/para +para + Properties are identified by a name that uniquely defines the property + purpose, and store an associated value. For all property types except blob + properties the value is a 64-bit unsigned integer. +/para +para + KMS differentiates between properties and property instances. Drivers + first create properties and then create and associate individual instances + of those properties to objects. A property can be instantiated multiple + times and associated with different objects. Values are stored in property + instances, and all other property information are stored in the propery + and shared between all instances of the property. +/para +para + Every property is created with a type that influences how the KMS core + handles the property. Supported property types are + variablelist +varlistentry + termDRM_MODE_PROP_RANGE/term + listitemparaRange properties report their minimum and maximum +admissible values. The KMS core verifies that values set by +application fit in that range./para/listitem +/varlistentry +varlistentry + termDRM_MODE_PROP_ENUM/term + listitemparaEnumerated properties take a numerical value that +ranges from 0 to the number of enumerated values defined by the +property minus one, and associate a free-formed string name to each +value. Applications can retrieve the list of defined value-name pairs +and use the numerical value to get and set property instance values. +/para/listitem +/varlistentry +varlistentry + termDRM_MODE_PROP_BITMASK/term + listitemparaBitmask properties are enumeration properties that +additionally restrict all enumerated values to the 0..63 range. +Bitmask property instance values combine one or more
Re: [PATCH 2/2] drm/doc: Document the KMS property API
Hi Hans, Thanks for the review. On Saturday 22 June 2013 15:32:43 Hans Verkuil wrote: Hi Laurent, Is this a hint to me that V4L2 should have a property API as well? :-) Honestly, not at all, but I'm of course willing to discuss the subject ;-) Anyway, I found some typos below: Thank you. I'll fix them in v2. -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v6 08/23] modetest: Add a command line parameter to set properties
Hi Ville, Thank you for the review. On Monday 24 June 2013 18:08:37 Ville Syrjälä wrote: On Fri, Jun 14, 2013 at 11:34:42PM +0200, Laurent Pinchart wrote: The -w parameter can be used to set a property value from the command line, using the target object ID and the property name. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 108 - 1 file changed, 106 insertions(+), 2 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 778af62..858d480 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c snip @@ -1008,9 +1082,20 @@ static int parse_plane(struct plane_arg *p, const char *arg) return 0; } +static int parse_property(struct property_arg *p, const char *arg) +{ + if (sscanf(arg, %d:%32[^:]:% SCNu64, p-obj_id, p-name, p- value) != 3) nit: could use stringification to get rid of the magic number 32 here. What do you mean exactly ? I didn't spot any real problems in the series. But I must admit that I mainly just glanced at most of the changes in since many of the diffs are a bit hard to read. I also gave it a quick try using sprites and setting a few modes. And I found a bug in i915 while doing that, so clearly it has already proved useful ;) That's nice to know :-) + return -1; + + p-obj_type = 0; + p-name[DRM_PROP_NAME_LEN] = '\0'; + + return 0; +} + static void usage(char *name) { - fprintf(stderr, usage: %s [-cdefMmPpsv]\n, name); + fprintf(stderr, usage: %s [-cdefMmPpsvw]\n, name); fprintf(stderr, \n Query options:\n\n); fprintf(stderr, \t-c\tlist connectors\n); -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v6 00/23] modetest enhancements
Hi Jerome, Marek, On Friday 14 June 2013 23:34:34 Laurent Pinchart wrote: Hello, Here's the sixth (and hopefully final) version of my modeset enhancements patch set. Beside various cleanups, these patches allow dropping master after mode set, configuring more than two pipes and planes, setting properties from the command line, setting plane positions and configuring pipes with multiple connectors in cloned mode. The code has been tested with the R-Car DU DRM driver. Any chance to get this series applied ? -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] gpu/host1x: Remove DRIVER_BUS_PLATFORM from driver_features
Hi Thierry, On Wednesday 29 May 2013 12:50:40 Thierry Reding wrote: On Wed, May 29, 2013 at 07:44:34AM +0200, Laurent Pinchart wrote: From: Laurent Pinchart laurent.pinch...@ideasonboard.com DRIVER_BUS_PLATFORM is not a DRM driver feature flag, it must not be set in the driver's driver_features field. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- drivers/gpu/host1x/drm/drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Applied, thanks. I did modify the subject's prefix to drm/tegra: for consistency, though. Do you plan to push the patch to v3.11 through Dave's tree ? I can't find it in drm-next. -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v6 08/23] modetest: Add a command line parameter to set properties
On Thursday 27 June 2013 11:31:48 Ville Syrjälä wrote: On Thu, Jun 27, 2013 at 10:10:43AM +0200, Laurent Pinchart wrote: On Monday 24 June 2013 18:08:37 Ville Syrjälä wrote: On Fri, Jun 14, 2013 at 11:34:42PM +0200, Laurent Pinchart wrote: The -w parameter can be used to set a property value from the command line, using the target object ID and the property name. Signed-off-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- tests/modetest/modetest.c | 108 - 1 file changed, 106 insertions(+), 2 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 778af62..858d480 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c snip @@ -1008,9 +1082,20 @@ static int parse_plane(struct plane_arg *p, const char *arg) return 0; } +static int parse_property(struct property_arg *p, const char *arg) +{ + if (sscanf(arg, %d:%32[^:]:% SCNu64, p-obj_id, p-name, p- value) != 3) nit: could use stringification to get rid of the magic number 32 here. What do you mean exactly ? Something like this: #define str(x) #x #define xstr(x) str(x) sscanf(arg, %d:% xstr(DRM_PROP_NAME_LEN) [^:]:% SCNu64, ... Although it does make it a bit hard to parse for a human. Right. I'm fine with both. %m[^:] might be an interesting alternative option. -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 01/24] drm/rcar-du: Add missing alpha plane register definitions
Several alpha plane register definitions are missing, add them. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_regs.h | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_regs.h b/drivers/gpu/drm/rcar-du/rcar_du_regs.h index 69f21f1..3aba27f 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_regs.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_regs.h @@ -349,10 +349,25 @@ #define APnMR_BM_AD(2 4)/* Auto Display Change Mode */ #define APnMWR 0x0a104 + +#define APnDSXR0x0a110 +#define APnDSYR0x0a114 +#define APnDPXR0x0a118 +#define APnDPYR0x0a11c + #define APnDSA0R 0x0a120 #define APnDSA1R 0x0a124 #define APnDSA2R 0x0a128 + +#define APnSPXR0x0a130 +#define APnSPYR0x0a134 +#define APnWASPR 0x0a138 +#define APnWAMWR 0x0a13c + +#define APnBTR 0x0a140 + #define APnMLR 0x0a150 +#define APnSWAPR 0x0a180 /* - * Display Capture Registers -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 00/24] R-Car DU DRM support for R8A7790
Hello, Here's a set of patches that adds support for the DU found in the R8A7790 SoC. Compared to the R8A7779 DU, the R8A7790 has a third CRTC, internal LVDS encoders and different output routing options. These patches are targetted at v3.12 so there's no rush (but please don't take that as an excuse to skip reviewing them :-)). Laurent Pinchart (24): drm/rcar-du: Add missing alpha plane register definitions drm/rcar-du: Use devm_ioremap_resource() drm/rcar-du: Add platform module device table drm/rcar-du: Don't ignore rcar_du_crtc_create() return value drm/rcar-du: Support per-CRTC clock and IRQ drm/rcar-du: Fix buffer pitch alignment drm/rcar-du: Clarify comment regarding plane Y source coordinate drm/rcar-du: Split LVDS encoder and connector drm/rcar-du: Split VGA encoder and connector drm/rcar-du: Merge LVDS and VGA encoder code drm/rcar-du: Rename platform data fields to match what they describe drm/rcar-du: Create rcar_du_planes structure drm/rcar-du: Rename rcar_du_plane_(init|register) to rcar_du_planes_* drm/rcar-du: Introduce CRTCs groups drm/rcar-du: Use dynamic number of CRTCs instead of CRTCs array size drm/rcar-du: Remove register definitions for the second channel drm/rcar-du: Move output routing configuration to group drm/rcar-du: Add support for the R8A7790 DU drm/rcar-du: Fix buffer pitch alignment for R8A7790 DU drm/rcar-du: Add support for multiple groups drm/rcar-du: Add support for DEFR8 register drm/rcar-du: Rework output routing support drm/rcar-du: Configure RGB output routing to DPAD0 drm/rcar-du: Add internal LVDS encoder support drivers/gpu/drm/rcar-du/Kconfig | 7 + drivers/gpu/drm/rcar-du/Makefile | 10 +- drivers/gpu/drm/rcar-du/rcar_du_crtc.c| 255 -- drivers/gpu/drm/rcar-du/rcar_du_crtc.h| 13 +- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 169 drivers/gpu/drm/rcar-du/rcar_du_drv.h | 61 +-- drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 202 +++ drivers/gpu/drm/rcar-du/rcar_du_encoder.h | 49 ++ drivers/gpu/drm/rcar-du/rcar_du_group.c | 187 ++ drivers/gpu/drm/rcar-du/rcar_du_group.h | 50 ++ drivers/gpu/drm/rcar-du/rcar_du_kms.c | 135 +--- drivers/gpu/drm/rcar-du/rcar_du_kms.h | 32 +--- drivers/gpu/drm/rcar-du/rcar_du_lvds.c| 216 - drivers/gpu/drm/rcar-du/rcar_du_lvds.h| 24 --- drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c | 130 +++ drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h | 25 +++ drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 194 +++ drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h | 46 ++ drivers/gpu/drm/rcar-du/rcar_du_plane.c | 170 ++-- drivers/gpu/drm/rcar-du/rcar_du_plane.h | 26 ++- drivers/gpu/drm/rcar-du/rcar_du_regs.h| 94 +-- drivers/gpu/drm/rcar-du/rcar_du_vga.c | 149 - drivers/gpu/drm/rcar-du/rcar_du_vga.h | 24 --- drivers/gpu/drm/rcar-du/rcar_du_vgacon.c | 96 +++ drivers/gpu/drm/rcar-du/rcar_du_vgacon.h | 23 +++ drivers/gpu/drm/rcar-du/rcar_lvds_regs.h | 69 include/linux/platform_data/rcar-du.h | 34 +++- 27 files changed, 1639 insertions(+), 851 deletions(-) create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_encoder.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_encoder.h create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_group.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_group.h delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvds.c delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvds.h create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vga.c delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vga.h create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vgacon.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vgacon.h create mode 100644 drivers/gpu/drm/rcar-du/rcar_lvds_regs.h -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 03/24] drm/rcar-du: Add platform module device table
The platform device id driver data field points to a device information structure that only contains a (currently empty) features field for now. Support for additional model-dependent features will be added later. Only the R8A7779 variant is currently supported. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 13 + drivers/gpu/drm/rcar-du/rcar_du_drv.h | 15 +++ 2 files changed, 28 insertions(+) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index 24ab0ca..d705990 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -123,6 +123,7 @@ static int rcar_du_load(struct drm_device *dev, unsigned long flags) rcdu-dev = pdev-dev; rcdu-pdata = pdata; + rcdu-info = (struct rcar_du_device_info *)pdev-id_entry-driver_data; rcdu-ddev = dev; dev-dev_private = rcdu; @@ -292,6 +293,17 @@ static int rcar_du_remove(struct platform_device *pdev) return 0; } +static const struct rcar_du_device_info rcar_du_r8a7779_info = { + .features = 0, +}; + +static const struct platform_device_id rcar_du_id_table[] = { + { rcar-du-r8a7779, (kernel_ulong_t)rcar_du_r8a7779_info }, + { } +}; + +MODULE_DEVICE_TABLE(platform, rcar_du_id_table); + static struct platform_driver rcar_du_platform_driver = { .probe = rcar_du_probe, .remove = rcar_du_remove, @@ -300,6 +312,7 @@ static struct platform_driver rcar_du_platform_driver = { .name = rcar-du, .pm = rcar_du_pm_ops, }, + .id_table = rcar_du_id_table, }; module_platform_driver(rcar_du_platform_driver); diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/rcar-du/rcar_du_drv.h index 193cc59..06dbf4f 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h @@ -25,9 +25,18 @@ struct clk; struct device; struct drm_device; +/* + * struct rcar_du_device_info - DU model-specific information + * @features: device features (RCAR_DU_FEATURE_*) + */ +struct rcar_du_device_info { + unsigned int features; +}; + struct rcar_du_device { struct device *dev; const struct rcar_du_platform_data *pdata; + const struct rcar_du_device_info *info; void __iomem *mmio; struct clk *clock; @@ -50,6 +59,12 @@ struct rcar_du_device { } planes; }; +static inline bool rcar_du_has(struct rcar_du_device *rcdu, + unsigned int feature) +{ + return rcdu-info-features feature; +} + int rcar_du_get(struct rcar_du_device *rcdu); void rcar_du_put(struct rcar_du_device *rcdu); -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 04/24] drm/rcar-du: Don't ignore rcar_du_crtc_create() return value
Handle error cases correctly. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 9c63f39..06cacf6 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -191,8 +191,11 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu) if (ret 0) return ret; - for (i = 0; i ARRAY_SIZE(rcdu-crtcs); ++i) - rcar_du_crtc_create(rcdu, i); + for (i = 0; i ARRAY_SIZE(rcdu-crtcs); ++i) { + ret = rcar_du_crtc_create(rcdu, i); + if (ret 0) + return ret; + } rcdu-used_crtcs = 0; rcdu-num_crtcs = i; -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 05/24] drm/rcar-du: Support per-CRTC clock and IRQ
Some of the DU revisions use one clock and IRQ per CRTC instead of one clock and IRQ per device. Retrieve the correct clock and register the correct IRQ for each CRTC. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 120 + drivers/gpu/drm/rcar-du/rcar_du_crtc.h | 2 +- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 52 +++--- drivers/gpu/drm/rcar-du/rcar_du_drv.h | 3 +- 4 files changed, 103 insertions(+), 74 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 24183fb..aefc8a0 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -69,6 +69,30 @@ static void rcar_du_crtc_clr_set(struct rcar_du_crtc *rcrtc, u32 reg, rcar_du_write(rcdu, rcrtc-mmio_offset + reg, (value ~clr) | set); } +static int rcar_du_crtc_get(struct rcar_du_crtc *rcrtc) +{ + struct rcar_du_device *rcdu = rcrtc-crtc.dev-dev_private; + int ret; + + ret = clk_prepare_enable(rcrtc-clock); + if (ret 0) + return ret; + + ret = rcar_du_get(rcdu); + if (ret 0) + clk_disable_unprepare(rcrtc-clock); + + return ret; +} + +static void rcar_du_crtc_put(struct rcar_du_crtc *rcrtc) +{ + struct rcar_du_device *rcdu = rcrtc-crtc.dev-dev_private; + + rcar_du_put(rcdu); + clk_disable_unprepare(rcrtc-clock); +} + static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) { struct drm_crtc *crtc = rcrtc-crtc; @@ -79,7 +103,7 @@ static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) u32 div; /* Dot clock */ - clk = clk_get_rate(rcdu-clock); + clk = clk_get_rate(rcrtc-clock); div = DIV_ROUND_CLOSEST(clk, mode-clock * 1000); div = clamp(div, 1U, 64U) - 1; @@ -313,20 +337,16 @@ static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc) void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc) { - struct rcar_du_device *rcdu = rcrtc-crtc.dev-dev_private; - rcar_du_crtc_stop(rcrtc); - rcar_du_put(rcdu); + rcar_du_crtc_put(rcrtc); } void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc) { - struct rcar_du_device *rcdu = rcrtc-crtc.dev-dev_private; - if (rcrtc-dpms != DRM_MODE_DPMS_ON) return; - rcar_du_get(rcdu); + rcar_du_crtc_get(rcrtc); rcar_du_crtc_start(rcrtc); } @@ -340,18 +360,17 @@ static void rcar_du_crtc_update_base(struct rcar_du_crtc *rcrtc) static void rcar_du_crtc_dpms(struct drm_crtc *crtc, int mode) { - struct rcar_du_device *rcdu = crtc-dev-dev_private; struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); if (rcrtc-dpms == mode) return; if (mode == DRM_MODE_DPMS_ON) { - rcar_du_get(rcdu); + rcar_du_crtc_get(rcrtc); rcar_du_crtc_start(rcrtc); } else { rcar_du_crtc_stop(rcrtc); - rcar_du_put(rcdu); + rcar_du_crtc_put(rcrtc); } rcrtc-dpms = mode; @@ -367,13 +386,12 @@ static bool rcar_du_crtc_mode_fixup(struct drm_crtc *crtc, static void rcar_du_crtc_mode_prepare(struct drm_crtc *crtc) { - struct rcar_du_device *rcdu = crtc-dev-dev_private; struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); /* We need to access the hardware during mode set, acquire a reference -* to the DU. +* to the CRTC. */ - rcar_du_get(rcdu); + rcar_du_crtc_get(rcrtc); /* Stop the CRTC and release the plane. Force the DPMS mode to off as a * result. @@ -423,10 +441,10 @@ static int rcar_du_crtc_mode_set(struct drm_crtc *crtc, error: /* There's no rollback/abort operation to clean up in case of error. We -* thus need to release the reference to the DU acquired in prepare() +* thus need to release the reference to the CRTC acquired in prepare() * here. */ - rcar_du_put(rcdu); + rcar_du_crtc_put(rcrtc); return ret; } @@ -514,6 +532,24 @@ static void rcar_du_crtc_finish_page_flip(struct rcar_du_crtc *rcrtc) drm_vblank_put(dev, rcrtc-index); } +static irqreturn_t rcar_du_crtc_irq(int irq, void *arg) +{ + struct rcar_du_crtc *rcrtc = arg; + irqreturn_t ret = IRQ_NONE; + u32 status; + + status = rcar_du_crtc_read(rcrtc, DSSR); + rcar_du_crtc_write(rcrtc, DSRCR, status DSRCR_MASK); + + if (status DSSR_VBK) { + drm_handle_vblank(rcrtc-crtc.dev, rcrtc-index); + rcar_du_crtc_finish_page_flip(rcrtc); + ret = IRQ_HANDLED; + } + + return ret; +} + static int rcar_du_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb
[PATCH 06/24] drm/rcar-du: Fix buffer pitch alignment
The DU requires a 16 pixels pitch alignement. Make sure dumb buffers are allocated with the correct pitch, and validate the pitch when creating frame buffers. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 19 ++- drivers/gpu/drm/rcar-du/rcar_du_kms.h | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index 2a85056..bcda2e0 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -200,7 +200,7 @@ static struct drm_driver rcar_du_driver = { .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_import = drm_gem_cma_dmabuf_import, .gem_prime_export = drm_gem_cma_dmabuf_export, - .dumb_create= drm_gem_cma_dumb_create, + .dumb_create= rcar_du_dumb_create, .dumb_map_offset= drm_gem_cma_dumb_map_offset, .dumb_destroy = drm_gem_cma_dumb_destroy, .fops = rcar_du_fops, diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 06cacf6..d30c2e2 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -138,11 +138,25 @@ void rcar_du_encoder_mode_commit(struct drm_encoder *encoder) * Frame buffer */ +int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, + struct drm_mode_create_dumb *args) +{ + unsigned int min_pitch = DIV_ROUND_UP(args-width * args-bpp, 8); + unsigned int align; + + /* The pitch must be aligned to a 16 pixels boundary. */ + align = 16 * args-bpp / 8; + args-pitch = roundup(max(args-pitch, min_pitch), align); + + return drm_gem_cma_dumb_create(file, dev, args); +} + static struct drm_framebuffer * rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd2 *mode_cmd) { const struct rcar_du_format_info *format; + unsigned int align; format = rcar_du_format_info(mode_cmd-pixel_format); if (format == NULL) { @@ -151,7 +165,10 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, return ERR_PTR(-EINVAL); } - if (mode_cmd-pitches[0] 15 || mode_cmd-pitches[0] = 8192) { + align = 16 * format-bpp / 8; + + if (mode_cmd-pitches[0] (align - 1) || + mode_cmd-pitches[0] = 8192) { dev_dbg(dev-dev, invalid pitch value %u\n, mode_cmd-pitches[0]); return ERR_PTR(-EINVAL); diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.h b/drivers/gpu/drm/rcar-du/rcar_du_kms.h index e4d8db0..dba4722 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.h @@ -56,4 +56,7 @@ void rcar_du_encoder_mode_commit(struct drm_encoder *encoder); int rcar_du_modeset_init(struct rcar_du_device *rcdu); +int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, + struct drm_mode_create_dumb *args); + #endif /* __RCAR_DU_KMS_H__ */ -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 07/24] drm/rcar-du: Clarify comment regarding plane Y source coordinate
The R8A7790 DU documentation contains further information regarding the plane Y source coordinate. Update the comment accordingly. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_plane.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c index a65f81d..38ebd20 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c @@ -103,9 +103,12 @@ void rcar_du_plane_update_base(struct rcar_du_plane *plane) struct rcar_du_device *rcdu = plane-dev; unsigned int index = plane-hwindex; - /* According to the datasheet the Y position is expressed in raster line -* units. However, 32bpp formats seem to require a doubled Y position -* value. Similarly, for the second plane, NV12 and NV21 formats seem to + /* The Y position is expressed in raster line units and must be doubled +* for 32bpp formats, according to the R8A7790 datasheet. No mention of +* doubling the Y position is found in the R8A7779 datasheet, but the +* rule seems to apply there as well. +* +* Similarly, for the second plane, NV12 and NV21 formats seem to * require a halved Y position value. */ rcar_du_plane_write(rcdu, index, PnSPXR, plane-src_x); -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 08/24] drm/rcar-du: Split LVDS encoder and connector
This prepares for the encoders rework. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/Makefile | 1 + drivers/gpu/drm/rcar-du/rcar_du_lvds.c| 120 +-- drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c | 129 ++ drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h | 25 ++ 4 files changed, 157 insertions(+), 118 deletions(-) create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile index 7333c00..5def510 100644 --- a/drivers/gpu/drm/rcar-du/Makefile +++ b/drivers/gpu/drm/rcar-du/Makefile @@ -2,6 +2,7 @@ rcar-du-drm-y := rcar_du_crtc.o \ rcar_du_drv.o \ rcar_du_kms.o \ rcar_du_lvds.o \ +rcar_du_lvdscon.o \ rcar_du_plane.o \ rcar_du_vga.o diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvds.c b/drivers/gpu/drm/rcar-du/rcar_du_lvds.c index 7aefe72..82e5157 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_lvds.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_lvds.c @@ -1,5 +1,5 @@ /* - * rcar_du_lvds.c -- R-Car Display Unit LVDS Encoder and Connector + * rcar_du_lvds.c -- R-Car Display Unit LVDS Encoder * * Copyright (C) 2013 Renesas Corporation * @@ -18,123 +18,7 @@ #include rcar_du_drv.h #include rcar_du_kms.h #include rcar_du_lvds.h - -struct rcar_du_lvds_connector { - struct rcar_du_connector connector; - - const struct rcar_du_panel_data *panel; -}; - -#define to_rcar_lvds_connector(c) \ - container_of(c, struct rcar_du_lvds_connector, connector.connector) - -/* - - * Connector - */ - -static int rcar_du_lvds_connector_get_modes(struct drm_connector *connector) -{ - struct rcar_du_lvds_connector *lvdscon = to_rcar_lvds_connector(connector); - struct drm_display_mode *mode; - - mode = drm_mode_create(connector-dev); - if (mode == NULL) - return 0; - - mode-type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; - mode-clock = lvdscon-panel-mode.clock; - mode-hdisplay = lvdscon-panel-mode.hdisplay; - mode-hsync_start = lvdscon-panel-mode.hsync_start; - mode-hsync_end = lvdscon-panel-mode.hsync_end; - mode-htotal = lvdscon-panel-mode.htotal; - mode-vdisplay = lvdscon-panel-mode.vdisplay; - mode-vsync_start = lvdscon-panel-mode.vsync_start; - mode-vsync_end = lvdscon-panel-mode.vsync_end; - mode-vtotal = lvdscon-panel-mode.vtotal; - mode-flags = lvdscon-panel-mode.flags; - - drm_mode_set_name(mode); - drm_mode_probed_add(connector, mode); - - return 1; -} - -static int rcar_du_lvds_connector_mode_valid(struct drm_connector *connector, - struct drm_display_mode *mode) -{ - return MODE_OK; -} - -static const struct drm_connector_helper_funcs connector_helper_funcs = { - .get_modes = rcar_du_lvds_connector_get_modes, - .mode_valid = rcar_du_lvds_connector_mode_valid, - .best_encoder = rcar_du_connector_best_encoder, -}; - -static void rcar_du_lvds_connector_destroy(struct drm_connector *connector) -{ - drm_sysfs_connector_remove(connector); - drm_connector_cleanup(connector); -} - -static enum drm_connector_status -rcar_du_lvds_connector_detect(struct drm_connector *connector, bool force) -{ - return connector_status_connected; -} - -static const struct drm_connector_funcs connector_funcs = { - .dpms = drm_helper_connector_dpms, - .detect = rcar_du_lvds_connector_detect, - .fill_modes = drm_helper_probe_single_connector_modes, - .destroy = rcar_du_lvds_connector_destroy, -}; - -static int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu, - struct rcar_du_encoder *renc, - const struct rcar_du_panel_data *panel) -{ - struct rcar_du_lvds_connector *lvdscon; - struct drm_connector *connector; - int ret; - - lvdscon = devm_kzalloc(rcdu-dev, sizeof(*lvdscon), GFP_KERNEL); - if (lvdscon == NULL) - return -ENOMEM; - - lvdscon-panel = panel; - - connector = lvdscon-connector.connector; - connector-display_info.width_mm = panel-width_mm; - connector-display_info.height_mm = panel-height_mm; - - ret = drm_connector_init(rcdu-ddev, connector, connector_funcs, -DRM_MODE_CONNECTOR_LVDS); - if (ret 0) - return ret; - - drm_connector_helper_add(connector, connector_helper_funcs); - ret = drm_sysfs_connector_add(connector); - if (ret 0) - return ret; - - drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF
[PATCH 09/24] drm/rcar-du: Split VGA encoder and connector
This prepares for the encoders rework. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/Makefile | 3 +- drivers/gpu/drm/rcar-du/rcar_du_vga.c| 86 + drivers/gpu/drm/rcar-du/rcar_du_vga.h| 2 +- drivers/gpu/drm/rcar-du/rcar_du_vgacon.c | 95 drivers/gpu/drm/rcar-du/rcar_du_vgacon.h | 23 5 files changed, 123 insertions(+), 86 deletions(-) create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vgacon.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vgacon.h diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile index 5def510..45a8479 100644 --- a/drivers/gpu/drm/rcar-du/Makefile +++ b/drivers/gpu/drm/rcar-du/Makefile @@ -4,6 +4,7 @@ rcar-du-drm-y := rcar_du_crtc.o \ rcar_du_lvds.o \ rcar_du_lvdscon.o \ rcar_du_plane.o \ -rcar_du_vga.o +rcar_du_vga.o \ +rcar_du_vgacon.o obj-$(CONFIG_DRM_RCAR_DU) += rcar-du-drm.o diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vga.c b/drivers/gpu/drm/rcar-du/rcar_du_vga.c index 327289e..369ab32 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vga.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_vga.c @@ -1,5 +1,5 @@ /* - * rcar_du_vga.c -- R-Car Display Unit VGA DAC and Connector + * rcar_du_vga.c -- R-Car Display Unit VGA DAC * * Copyright (C) 2013 Renesas Corporation * @@ -18,89 +18,7 @@ #include rcar_du_drv.h #include rcar_du_kms.h #include rcar_du_vga.h - -/* - - * Connector - */ - -static int rcar_du_vga_connector_get_modes(struct drm_connector *connector) -{ - return 0; -} - -static int rcar_du_vga_connector_mode_valid(struct drm_connector *connector, - struct drm_display_mode *mode) -{ - return MODE_OK; -} - -static const struct drm_connector_helper_funcs connector_helper_funcs = { - .get_modes = rcar_du_vga_connector_get_modes, - .mode_valid = rcar_du_vga_connector_mode_valid, - .best_encoder = rcar_du_connector_best_encoder, -}; - -static void rcar_du_vga_connector_destroy(struct drm_connector *connector) -{ - drm_sysfs_connector_remove(connector); - drm_connector_cleanup(connector); -} - -static enum drm_connector_status -rcar_du_vga_connector_detect(struct drm_connector *connector, bool force) -{ - return connector_status_unknown; -} - -static const struct drm_connector_funcs connector_funcs = { - .dpms = drm_helper_connector_dpms, - .detect = rcar_du_vga_connector_detect, - .fill_modes = drm_helper_probe_single_connector_modes, - .destroy = rcar_du_vga_connector_destroy, -}; - -static int rcar_du_vga_connector_init(struct rcar_du_device *rcdu, - struct rcar_du_encoder *renc) -{ - struct rcar_du_connector *rcon; - struct drm_connector *connector; - int ret; - - rcon = devm_kzalloc(rcdu-dev, sizeof(*rcon), GFP_KERNEL); - if (rcon == NULL) - return -ENOMEM; - - connector = rcon-connector; - connector-display_info.width_mm = 0; - connector-display_info.height_mm = 0; - - ret = drm_connector_init(rcdu-ddev, connector, connector_funcs, -DRM_MODE_CONNECTOR_VGA); - if (ret 0) - return ret; - - drm_connector_helper_add(connector, connector_helper_funcs); - ret = drm_sysfs_connector_add(connector); - if (ret 0) - return ret; - - drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); - drm_object_property_set_value(connector-base, - rcdu-ddev-mode_config.dpms_property, DRM_MODE_DPMS_OFF); - - ret = drm_mode_connector_attach_encoder(connector, renc-encoder); - if (ret 0) - return ret; - - connector-encoder = renc-encoder; - rcon-encoder = renc; - - return 0; -} - -/* - - * Encoder - */ +#include rcar_du_vgacon.h static void rcar_du_vga_encoder_dpms(struct drm_encoder *encoder, int mode) { diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vga.h b/drivers/gpu/drm/rcar-du/rcar_du_vga.h index 66b4d2d..b969b20 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vga.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_vga.h @@ -1,5 +1,5 @@ /* - * rcar_du_vga.h -- R-Car Display Unit VGA DAC and Connector + * rcar_du_vga.h -- R-Car Display Unit VGA DAC * * Copyright (C) 2013 Renesas Corporation * diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c b/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c new file mode 100644 index 000..2ee3203 --- /dev/null +++ b/drivers/gpu/drm/rcar-du/rcar_du_vgacon.c @@ -0,0 +1,95 @@ +/* + * rcar_du_vgacon.c -- R-Car Display Unit VGA Connector + * + * Copyright (C
[PATCH 10/24] drm/rcar-du: Merge LVDS and VGA encoder code
Create a single rcar_du_encoder structure that implements a KMS encoder. The current implementation is straightforward and only configures CRTC output routing. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/Makefile | 3 +- drivers/gpu/drm/rcar-du/rcar_du_crtc.c| 2 - drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 148 ++ drivers/gpu/drm/rcar-du/rcar_du_encoder.h | 45 + drivers/gpu/drm/rcar-du/rcar_du_kms.c | 49 ++ drivers/gpu/drm/rcar-du/rcar_du_kms.h | 29 +- drivers/gpu/drm/rcar-du/rcar_du_lvds.c| 100 drivers/gpu/drm/rcar-du/rcar_du_lvds.h| 24 - drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c | 1 + drivers/gpu/drm/rcar-du/rcar_du_vga.c | 67 -- drivers/gpu/drm/rcar-du/rcar_du_vga.h | 24 - drivers/gpu/drm/rcar-du/rcar_du_vgacon.c | 1 + 12 files changed, 205 insertions(+), 288 deletions(-) create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_encoder.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_encoder.h delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvds.c delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvds.h delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vga.c delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vga.h diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile index 45a8479..57b0fe1 100644 --- a/drivers/gpu/drm/rcar-du/Makefile +++ b/drivers/gpu/drm/rcar-du/Makefile @@ -1,10 +1,9 @@ rcar-du-drm-y := rcar_du_crtc.o \ rcar_du_drv.o \ +rcar_du_encoder.o \ rcar_du_kms.o \ -rcar_du_lvds.o \ rcar_du_lvdscon.o \ rcar_du_plane.o \ -rcar_du_vga.o \ rcar_du_vgacon.o obj-$(CONFIG_DRM_RCAR_DU) += rcar-du-drm.o diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index aefc8a0..03dd701 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -23,10 +23,8 @@ #include rcar_du_crtc.h #include rcar_du_drv.h #include rcar_du_kms.h -#include rcar_du_lvds.h #include rcar_du_plane.h #include rcar_du_regs.h -#include rcar_du_vga.h #define to_rcar_crtc(c)container_of(c, struct rcar_du_crtc, crtc) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c new file mode 100644 index 000..15a5643 --- /dev/null +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c @@ -0,0 +1,148 @@ +/* + * rcar_du_encoder.c -- R-Car Display Unit Encoder + * + * Copyright (C) 2013 Renesas Corporation + * + * Contact: Laurent Pinchart (laurent.pinch...@ideasonboard.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include drm/drmP.h +#include drm/drm_crtc.h +#include drm/drm_crtc_helper.h + +#include rcar_du_drv.h +#include rcar_du_encoder.h +#include rcar_du_kms.h +#include rcar_du_lvdscon.h +#include rcar_du_vgacon.h + +/* - + * Common connector functions + */ + +struct drm_encoder * +rcar_du_connector_best_encoder(struct drm_connector *connector) +{ + struct rcar_du_connector *rcon = to_rcar_connector(connector); + + return rcon-encoder-encoder; +} + +/* - + * Encoder + */ + +static void rcar_du_encoder_dpms(struct drm_encoder *encoder, int mode) +{ +} + +static bool rcar_du_encoder_mode_fixup(struct drm_encoder *encoder, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + const struct drm_display_mode *panel_mode; + struct drm_device *dev = encoder-dev; + struct drm_connector *connector; + bool found = false; + + /* DAC encoders have currently no restriction on the mode. */ + if (encoder-encoder_type == DRM_MODE_ENCODER_DAC) + return true; + + list_for_each_entry(connector, dev-mode_config.connector_list, head) { + if (connector-encoder == encoder) { + found = true; + break; + } + } + + if (!found) { + dev_dbg(dev-dev, mode_fixup: no connector found\n); + return false; + } + + if (list_empty(connector-modes)) { + dev_dbg(dev-dev, mode_fixup: empty modes list\n); + return false; + } + + panel_mode = list_first_entry(connector-modes, + struct drm_display_mode, head
[PATCH 12/24] drm/rcar-du: Create rcar_du_planes structure
Move the plane-related fields of struct rcar_du_device to their own structure. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.h | 11 +-- drivers/gpu/drm/rcar-du/rcar_du_plane.h | 17 +++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/rcar-du/rcar_du_drv.h index 7d2320f..0305c21 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h @@ -15,7 +15,6 @@ #define __RCAR_DU_DRV_H__ #include linux/kernel.h -#include linux/mutex.h #include linux/platform_data/rcar-du.h #include rcar_du_crtc.h @@ -49,15 +48,7 @@ struct rcar_du_device { unsigned int used_crtcs; unsigned int num_crtcs; - struct { - struct rcar_du_plane planes[RCAR_DU_NUM_SW_PLANES]; - unsigned int free; - struct mutex lock; - - struct drm_property *alpha; - struct drm_property *colorkey; - struct drm_property *zpos; - } planes; + struct rcar_du_planes planes; }; static inline bool rcar_du_has(struct rcar_du_device *rcdu, diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.h b/drivers/gpu/drm/rcar-du/rcar_du_plane.h index 5397dba..5c8488c 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.h @@ -14,8 +14,11 @@ #ifndef __RCAR_DU_PLANE_H__ #define __RCAR_DU_PLANE_H__ -struct drm_crtc; -struct drm_framebuffer; +#include linux/mutex.h + +#include drm/drmP.h +#include drm/drm_crtc.h + struct rcar_du_device; struct rcar_du_format_info; @@ -54,6 +57,16 @@ struct rcar_du_plane { unsigned int dst_y; }; +struct rcar_du_planes { + struct rcar_du_plane planes[RCAR_DU_NUM_SW_PLANES]; + unsigned int free; + struct mutex lock; + + struct drm_property *alpha; + struct drm_property *colorkey; + struct drm_property *zpos; +}; + int rcar_du_plane_init(struct rcar_du_device *rcdu); int rcar_du_plane_register(struct rcar_du_device *rcdu); void rcar_du_plane_setup(struct rcar_du_plane *plane); -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 11/24] drm/rcar-du: Rename platform data fields to match what they describe
The struct rcar_du_encoder_data encoder::field describes the encoder type, and the rcar_du_encoder_lvds_data and rcar_du_encoder_vga_data structures describe connector properties. Rename them accordingly. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_encoder.h | 3 ++- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 5 ++--- include/linux/platform_data/rcar-du.h | 19 +-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c index 15a5643..0d0375c 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.c @@ -137,7 +137,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu, switch (type) { case RCAR_DU_ENCODER_LVDS: return rcar_du_lvds_connector_init(rcdu, renc, - data-u.lvds.panel); + data-connector.lvds.panel); case RCAR_DU_ENCODER_VGA: return rcar_du_vga_connector_init(rcdu, renc); diff --git a/drivers/gpu/drm/rcar-du/rcar_du_encoder.h b/drivers/gpu/drm/rcar-du/rcar_du_encoder.h index 4f76e16..08cde12 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_encoder.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_encoder.h @@ -14,10 +14,11 @@ #ifndef __RCAR_DU_ENCODER_H__ #define __RCAR_DU_ENCODER_H__ +#include linux/platform_data/rcar-du.h + #include drm/drm_crtc.h struct rcar_du_device; -struct rcar_du_encoder_data; struct rcar_du_encoder { struct drm_encoder encoder; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 3f8483c..a8eef16 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -191,7 +191,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu) const struct rcar_du_encoder_data *pdata = rcdu-pdata-encoders[i]; - if (pdata-encoder == RCAR_DU_ENCODER_UNUSED) + if (pdata-type == RCAR_DU_ENCODER_UNUSED) continue; if (pdata-output = ARRAY_SIZE(rcdu-crtcs)) { @@ -201,8 +201,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu) continue; } - rcar_du_encoder_init(rcdu, pdata-encoder, pdata-output, -pdata); + rcar_du_encoder_init(rcdu, pdata-type, pdata-output, pdata); } /* Set the possible CRTCs and possible clones. All encoders can be diff --git a/include/linux/platform_data/rcar-du.h b/include/linux/platform_data/rcar-du.h index 80587fd..64cd863 100644 --- a/include/linux/platform_data/rcar-du.h +++ b/include/linux/platform_data/rcar-du.h @@ -28,22 +28,29 @@ struct rcar_du_panel_data { struct drm_mode_modeinfo mode; }; -struct rcar_du_encoder_lvds_data { +struct rcar_du_connector_lvds_data { struct rcar_du_panel_data panel; }; -struct rcar_du_encoder_vga_data { +struct rcar_du_connector_vga_data { /* TODO: Add DDC information for EDID retrieval */ }; +/* + * struct rcar_du_encoder_data - Encoder platform data + * @type: the encoder type (RCAR_DU_ENCODER_*) + * @output: the DU output the connector is connected to + * @connector.lvds: platform data for LVDS connectors + * @connector.vga: platform data for VGA connectors + */ struct rcar_du_encoder_data { - enum rcar_du_encoder_type encoder; + enum rcar_du_encoder_type type; unsigned int output; union { - struct rcar_du_encoder_lvds_data lvds; - struct rcar_du_encoder_vga_data vga; - } u; + struct rcar_du_connector_lvds_data lvds; + struct rcar_du_connector_vga_data vga; + } connector; }; struct rcar_du_platform_data { -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 13/24] drm/rcar-du: Rename rcar_du_plane_(init|register) to rcar_du_planes_*
The functions initialize or register all planes, rename them accordingly. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 4 ++-- drivers/gpu/drm/rcar-du/rcar_du_plane.c | 4 ++-- drivers/gpu/drm/rcar-du/rcar_du_plane.h | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index a8eef16..a1343fb 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -174,7 +174,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu) rcdu-ddev-mode_config.max_height = 2047; rcdu-ddev-mode_config.funcs = rcar_du_mode_config_funcs; - ret = rcar_du_plane_init(rcdu); + ret = rcar_du_planes_init(rcdu); if (ret 0) return ret; @@ -215,7 +215,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu) encoder-possible_clones = 1 0; } - ret = rcar_du_plane_register(rcdu); + ret = rcar_du_planes_register(rcdu); if (ret 0) return ret; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c index 38ebd20..29f2147 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c @@ -435,7 +435,7 @@ static const uint32_t formats[] = { DRM_FORMAT_NV16, }; -int rcar_du_plane_init(struct rcar_du_device *rcdu) +int rcar_du_planes_init(struct rcar_du_device *rcdu) { unsigned int i; @@ -475,7 +475,7 @@ int rcar_du_plane_init(struct rcar_du_device *rcdu) return 0; } -int rcar_du_plane_register(struct rcar_du_device *rcdu) +int rcar_du_planes_register(struct rcar_du_device *rcdu) { unsigned int i; int ret; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.h b/drivers/gpu/drm/rcar-du/rcar_du_plane.h index 5c8488c..bcf6f76 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.h @@ -67,8 +67,9 @@ struct rcar_du_planes { struct drm_property *zpos; }; -int rcar_du_plane_init(struct rcar_du_device *rcdu); -int rcar_du_plane_register(struct rcar_du_device *rcdu); +int rcar_du_planes_init(struct rcar_du_device *rcdu); +int rcar_du_planes_register(struct rcar_du_device *rcdu); + void rcar_du_plane_setup(struct rcar_du_plane *plane); void rcar_du_plane_update_base(struct rcar_du_plane *plane); void rcar_du_plane_compute_base(struct rcar_du_plane *plane, -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 14/24] drm/rcar-du: Introduce CRTCs groups
The R8A7779 DU is split in per-CRTC resources (scan-out engine, blending unit, timings generator, ...) and device-global resources (start/stop control, planes, ...) shared between the two CRTCs. The R8A7790 introduced a third CRTC with its own set of global resources This would be modeled as two separate DU device instances if it wasn't for a handful or resources that are shared between the three CRTCs (mostly related to input and output routing). For this reason the R8A7790 DU must be modeled as a single device with three CRTCs, two sets of semi-global resources, and a few device-global resources. Introduce a new rcar_du_group driver-specific object, without any real counterpart in the DU documentation, that models those semi-global resources. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/Makefile| 1 + drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 92 ++- drivers/gpu/drm/rcar-du/rcar_du_crtc.h | 5 +- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 46 -- drivers/gpu/drm/rcar-du/rcar_du_drv.h | 10 +-- drivers/gpu/drm/rcar-du/rcar_du_group.c | 127 ++ drivers/gpu/drm/rcar-du/rcar_du_group.h | 47 ++ drivers/gpu/drm/rcar-du/rcar_du_kms.c | 11 ++- drivers/gpu/drm/rcar-du/rcar_du_plane.c | 155 drivers/gpu/drm/rcar-du/rcar_du_plane.h | 8 +- 10 files changed, 299 insertions(+), 203 deletions(-) create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_group.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_group.h diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile index 57b0fe1..b9b5e66 100644 --- a/drivers/gpu/drm/rcar-du/Makefile +++ b/drivers/gpu/drm/rcar-du/Makefile @@ -1,6 +1,7 @@ rcar-du-drm-y := rcar_du_crtc.o \ rcar_du_drv.o \ rcar_du_encoder.o \ +rcar_du_group.o \ rcar_du_kms.o \ rcar_du_lvdscon.o \ rcar_du_plane.o \ diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 03dd701..7784a3b 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -30,21 +30,21 @@ static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg) { - struct rcar_du_device *rcdu = rcrtc-crtc.dev-dev_private; + struct rcar_du_device *rcdu = rcrtc-group-dev; return rcar_du_read(rcdu, rcrtc-mmio_offset + reg); } static void rcar_du_crtc_write(struct rcar_du_crtc *rcrtc, u32 reg, u32 data) { - struct rcar_du_device *rcdu = rcrtc-crtc.dev-dev_private; + struct rcar_du_device *rcdu = rcrtc-group-dev; rcar_du_write(rcdu, rcrtc-mmio_offset + reg, data); } static void rcar_du_crtc_clr(struct rcar_du_crtc *rcrtc, u32 reg, u32 clr) { - struct rcar_du_device *rcdu = rcrtc-crtc.dev-dev_private; + struct rcar_du_device *rcdu = rcrtc-group-dev; rcar_du_write(rcdu, rcrtc-mmio_offset + reg, rcar_du_read(rcdu, rcrtc-mmio_offset + reg) ~clr); @@ -52,7 +52,7 @@ static void rcar_du_crtc_clr(struct rcar_du_crtc *rcrtc, u32 reg, u32 clr) static void rcar_du_crtc_set(struct rcar_du_crtc *rcrtc, u32 reg, u32 set) { - struct rcar_du_device *rcdu = rcrtc-crtc.dev-dev_private; + struct rcar_du_device *rcdu = rcrtc-group-dev; rcar_du_write(rcdu, rcrtc-mmio_offset + reg, rcar_du_read(rcdu, rcrtc-mmio_offset + reg) | set); @@ -61,7 +61,7 @@ static void rcar_du_crtc_set(struct rcar_du_crtc *rcrtc, u32 reg, u32 set) static void rcar_du_crtc_clr_set(struct rcar_du_crtc *rcrtc, u32 reg, u32 clr, u32 set) { - struct rcar_du_device *rcdu = rcrtc-crtc.dev-dev_private; + struct rcar_du_device *rcdu = rcrtc-group-dev; u32 value = rcar_du_read(rcdu, rcrtc-mmio_offset + reg); rcar_du_write(rcdu, rcrtc-mmio_offset + reg, (value ~clr) | set); @@ -69,14 +69,13 @@ static void rcar_du_crtc_clr_set(struct rcar_du_crtc *rcrtc, u32 reg, static int rcar_du_crtc_get(struct rcar_du_crtc *rcrtc) { - struct rcar_du_device *rcdu = rcrtc-crtc.dev-dev_private; int ret; ret = clk_prepare_enable(rcrtc-clock); if (ret 0) return ret; - ret = rcar_du_get(rcdu); + ret = rcar_du_group_get(rcrtc-group); if (ret 0) clk_disable_unprepare(rcrtc-clock); @@ -85,17 +84,14 @@ static int rcar_du_crtc_get(struct rcar_du_crtc *rcrtc) static void rcar_du_crtc_put(struct rcar_du_crtc *rcrtc) { - struct rcar_du_device *rcdu = rcrtc-crtc.dev-dev_private; - - rcar_du_put(rcdu); + rcar_du_group_put(rcrtc-group); clk_disable_unprepare(rcrtc-clock); } static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) { - struct drm_crtc *crtc = rcrtc-crtc; - struct
[PATCH 15/24] drm/rcar-du: Use dynamic number of CRTCs instead of CRTCs array size
The rcar_du_device structure contains a field that stores the number of CRTCs, use it instead of the CRTCs array size. This prepares the driver to support a variable number of CRTCs. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index 5e4168d..fe61962 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -105,7 +105,7 @@ static void rcar_du_preclose(struct drm_device *dev, struct drm_file *file) struct rcar_du_device *rcdu = dev-dev_private; unsigned int i; - for (i = 0; i ARRAY_SIZE(rcdu-crtcs); ++i) + for (i = 0; i rcdu-num_crtcs; ++i) rcar_du_crtc_cancel_page_flip(rcdu-crtcs[i], file); } diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index c32e0f9..845bcb3 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -197,7 +197,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu) if (pdata-type == RCAR_DU_ENCODER_UNUSED) continue; - if (pdata-output = ARRAY_SIZE(rcdu-crtcs)) { + if (pdata-output = rcdu-num_crtcs) { dev_warn(rcdu-dev, encoder %u references unexisting output %u, skipping\n, i, pdata-output); -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 16/24] drm/rcar-du: Remove register definitions for the second channel
Channels are accessed through a global channel memory offset, there's no need to define register addresses for the second channel. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_regs.h | 9 - 1 file changed, 9 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_regs.h b/drivers/gpu/drm/rcar-du/rcar_du_regs.h index 3aba27f..195ed7e 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_regs.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_regs.h @@ -20,7 +20,6 @@ */ #define DSYSR 0x0 /* display 1 */ -#define D2SYSR 0x3 /* display 2 */ #define DSYSR_ILTS (1 29) #define DSYSR_DSEC (1 20) #define DSYSR_IUPD (1 16) @@ -35,7 +34,6 @@ #define DSYSR_SCM_INT_VIDEO(3 4) #define DSMR 0x4 -#define D2SMR 0x30004 #define DSMR_VSPM (1 28) #define DSMR_ODPM (1 27) #define DSMR_DIPM_DISP (0 25) @@ -60,7 +58,6 @@ #define DSMR_CSY_MASK (3 6) #define DSSR 0x8 -#define D2SSR 0x30008 #define DSSR_VC1FB_DSA0(0 30) #define DSSR_VC1FB_DSA1(1 30) #define DSSR_VC1FB_DSA2(2 30) @@ -80,7 +77,6 @@ #define DSSR_ADC(n)(1 ((n)-1)) #define DSRCR 0xc -#define D2SRCR 0x3000c #define DSRCR_TVCL (1 15) #define DSRCR_FRCL (1 14) #define DSRCR_VBCL (1 11) @@ -90,7 +86,6 @@ #define DSRCR_MASK 0xcbff #define DIER 0x00010 -#define D2IER 0x30010 #define DIER_TVE (1 15) #define DIER_FRE (1 14) #define DIER_VBE (1 11) @@ -114,7 +109,6 @@ #define DPPR_BPP32 (DPPR_BPP32_P1 | DPPR_BPP32_P2) /* plane1 2 */ #define DEFR 0x00020 -#define D2EFR 0x30020 #define DEFR_CODE (0x7773 16) #define DEFR_EXSL (1 12) #define DEFR_EXVL (1 11) @@ -137,12 +131,10 @@ #define DCPCR_DCE (1 0) #define DEFR2 0x00034 -#define D2EFR2 0x30034 #define DEFR2_CODE (0x7775 16) #define DEFR2_DEFE2G (1 0) #define DEFR3 0x00038 -#define D2EFR3 0x30038 #define DEFR3_CODE (0x7776 16) #define DEFR3_EVDA (1 14) #define DEFR3_EVDM_1 (1 12) @@ -153,7 +145,6 @@ #define DEFR3_DEFE3(1 0) #define DEFR4 0x0003c -#define D2EFR4 0x3003c #define DEFR4_CODE (0x 16) #define DEFR4_LRUO (1 5) #define DEFR4_SPCE (1 4) -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 17/24] drm/rcar-du: Move output routing configuration to group
Output routing is configured in group registers, move the corresponding code from rcar_du_crtc.c to rcar_du_group.c. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 21 + drivers/gpu/drm/rcar-du/rcar_du_group.c | 19 +++ drivers/gpu/drm/rcar-du/rcar_du_group.h | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 7784a3b..6a2b959 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -130,25 +130,6 @@ static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) rcar_du_crtc_write(rcrtc, DEWR, mode-hdisplay); } -static void rcar_du_crtc_set_routing(struct rcar_du_crtc *rcrtc) -{ - struct rcar_du_device *rcdu = rcrtc-group-dev; - u32 dorcr = rcar_du_read(rcdu, DORCR); - - dorcr = ~(DORCR_PG2T | DORCR_DK2S | DORCR_PG2D_MASK); - - /* Set the DU1 pins sources. Select CRTC 0 if explicitly requested and -* CRTC 1 in all other cases to avoid cloning CRTC 0 to DU0 and DU1 by -* default. -*/ - if (rcrtc-outputs (1 1) rcrtc-index == 0) - dorcr |= DORCR_PG2D_DS1; - else - dorcr |= DORCR_PG2T | DORCR_DK2S | DORCR_PG2D_DS2; - - rcar_du_write(rcdu, DORCR, dorcr); -} - void rcar_du_crtc_route_output(struct drm_crtc *crtc, unsigned int output) { struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); @@ -245,7 +226,7 @@ static void rcar_du_crtc_start(struct rcar_du_crtc *rcrtc) /* Configure display timings and output routing */ rcar_du_crtc_set_display_timing(rcrtc); - rcar_du_crtc_set_routing(rcrtc); + rcar_du_group_set_routing(rcrtc-group); mutex_lock(rcrtc-group-planes.lock); rcrtc-plane-enabled = true; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c b/drivers/gpu/drm/rcar-du/rcar_du_group.c index 625b9f4..7e75451 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_group.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c @@ -125,3 +125,22 @@ void rcar_du_group_restart(struct rcar_du_group *rgrp) __rcar_du_group_start_stop(rgrp, false); __rcar_du_group_start_stop(rgrp, true); } + +void rcar_du_group_set_routing(struct rcar_du_group *rgrp) +{ + struct rcar_du_crtc *crtc0 = rgrp-dev-crtcs[rgrp-index * 2]; + u32 dorcr = rcar_du_group_read(rgrp, DORCR); + + dorcr = ~(DORCR_PG2T | DORCR_DK2S | DORCR_PG2D_MASK); + + /* Set the DU1 pins sources. Select CRTC 0 if explicitly requested and +* CRTC 1 in all other cases to avoid cloning CRTC 0 to DU0 and DU1 by +* default. +*/ + if (crtc0-outputs (1 1)) + dorcr |= DORCR_PG2D_DS1; + else + dorcr |= DORCR_PG2T | DORCR_DK2S | DORCR_PG2D_DS2; + + rcar_du_group_write(rgrp, DORCR, dorcr); +} diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.h b/drivers/gpu/drm/rcar-du/rcar_du_group.h index 748331b..180c739 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_group.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_group.h @@ -42,6 +42,6 @@ int rcar_du_group_get(struct rcar_du_group *rgrp); void rcar_du_group_put(struct rcar_du_group *rgrp); void rcar_du_group_start_stop(struct rcar_du_group *rgrp, bool start); void rcar_du_group_restart(struct rcar_du_group *rgrp); - +void rcar_du_group_set_routing(struct rcar_du_group *rgrp); #endif /* __RCAR_DU_GROUP_H__ */ -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 18/24] drm/rcar-du: Add support for the R8A7790 DU
The DU revision in the R8A7790 SoC uses one IRQ and clock per CRTC. Add a corresponding entry in the module platform ID table. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 5 +++ drivers/gpu/drm/rcar-du/rcar_du_regs.h | 66 -- 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index fe61962..9c7406c 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -215,8 +215,13 @@ static const struct rcar_du_device_info rcar_du_r8a7779_info = { .features = 0, }; +static const struct rcar_du_device_info rcar_du_r8a7790_info = { + .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK, +}; + static const struct platform_device_id rcar_du_id_table[] = { { rcar-du-r8a7779, (kernel_ulong_t)rcar_du_r8a7779_info }, + { rcar-du-r8a7790, (kernel_ulong_t)rcar_du_r8a7790_info }, { } }; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_regs.h b/drivers/gpu/drm/rcar-du/rcar_du_regs.h index 195ed7e..f62a9f3 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_regs.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_regs.h @@ -196,6 +196,68 @@ #define DEFR6_DEFAULT (DEFR6_CODE | DEFR6_TCNE2) /* - + * R8A7790-only Control Registers + */ + +#define DD1SSR 0x20008 +#define DD1SSR_TVR (1 15) +#define DD1SSR_FRM (1 14) +#define DD1SSR_BUF (1 12) +#define DD1SSR_VBK (1 11) +#define DD1SSR_RINT(1 9) +#define DD1SSR_HBK (1 8) +#define DD1SSR_ADC(n) (1 ((n)-1)) + +#define DD1SRCR0x2000c +#define DD1SRCR_TVR(1 15) +#define DD1SRCR_FRM(1 14) +#define DD1SRCR_BUF(1 12) +#define DD1SRCR_VBK(1 11) +#define DD1SRCR_RINT (1 9) +#define DD1SRCR_HBK(1 8) +#define DD1SRCR_ADC(n) (1 ((n)-1)) + +#define DD1IER 0x20010 +#define DD1IER_TVR (1 15) +#define DD1IER_FRM (1 14) +#define DD1IER_BUF (1 12) +#define DD1IER_VBK (1 11) +#define DD1IER_RINT(1 9) +#define DD1IER_HBK (1 8) +#define DD1IER_ADC(n) (1 ((n)-1)) + +#define DEFR8 0x20020 +#define DEFR8_CODE (0x7790 16) +#define DEFR8_VSCS (1 6) +#define DEFR8_DRGBS_DU(n) ((n) 4) +#define DEFR8_DRGBS_MASK (3 4) +#define DEFR8_DEFE8(1 0) + +#define DOFLR 0x20024 +#define DOFLR_CODE (0x7790 16) +#define DOFLR_HSYCFL1 (1 13) +#define DOFLR_VSYCFL1 (1 12) +#define DOFLR_ODDFL1 (1 11) +#define DOFLR_DISPFL1 (1 10) +#define DOFLR_CDEFL1 (1 9) +#define DOFLR_RGBFL1 (1 8) +#define DOFLR_HSYCFL0 (1 5) +#define DOFLR_VSYCFL0 (1 4) +#define DOFLR_ODDFL0 (1 3) +#define DOFLR_DISPFL0 (1 2) +#define DOFLR_CDEFL0 (1 1) +#define DOFLR_RGBFL0 (1 0) + +#define DIDSR 0x20028 +#define DIDSR_CODE (0x7790 16) +#define DIDSR_LCDS_DCLKIN(n) (0 (8 + (n) * 2)) +#define DIDSR_LCDS_LVDS0(n)(2 (8 + (n) * 2)) +#define DIDSR_LCDS_LVDS1(n)(3 (8 + (n) * 2)) +#define DIDSR_LCDS_MASK(n) (3 (8 + (n) * 2)) +#define DIDSR_PCDS_CLK(n, clk) (clk ((n) * 2)) +#define DIDSR_PCDS_MASK(n) (3 ((n) * 2)) + +/* - * Display Timing Generation Registers */ @@ -364,12 +426,10 @@ * Display Capture Registers */ +#define DCMR 0x0c100 #define DCMWR 0x0c104 -#define DC2MWR 0x0c204 #define DCSAR 0x0c120 -#define DC2SAR 0x0c220 #define DCMLR 0x0c150 -#define DC2MLR 0x0c250 /* - * Color Palette Registers -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 19/24] drm/rcar-du: Fix buffer pitch alignment for R8A7790 DU
The R8A7790 DU seems to require a 128 bytes pitch alignment, even though the documentation only mentions a 16 pixels alignement as for the R8A7779 DU. Make this configurable through a device flag. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_drv.h | 1 + drivers/gpu/drm/rcar-du/rcar_du_kms.c | 17 ++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index 9c7406c..fe93670 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -216,7 +216,7 @@ static const struct rcar_du_device_info rcar_du_r8a7779_info = { }; static const struct rcar_du_device_info rcar_du_r8a7790_info = { - .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK, + .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_ALIGN_128B, }; static const struct platform_device_id rcar_du_id_table[] = { diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/rcar-du/rcar_du_drv.h index 5b57a2f..072e28e 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h @@ -26,6 +26,7 @@ struct drm_device; struct rcar_du_device; #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 0)/* Per-CRTC IRQ and clock */ +#define RCAR_DU_FEATURE_ALIGN_128B (1 1)/* Align pitches to 128 bytes */ /* * struct rcar_du_device_info - DU model-specific information diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 845bcb3..418d902 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -111,11 +111,18 @@ const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc) int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args) { + struct rcar_du_device *rcdu = dev-dev_private; unsigned int min_pitch = DIV_ROUND_UP(args-width * args-bpp, 8); unsigned int align; - /* The pitch must be aligned to a 16 pixels boundary. */ - align = 16 * args-bpp / 8; + /* The R8A7779 DU requires a 16 pixels pitch alignment as documented, +* but the R8A7790 DU seems to require a 128 bytes pitch alignment. +*/ + if (rcar_du_has(rcdu, RCAR_DU_FEATURE_ALIGN_128B)) + align = 128; + else + align = 16 * args-bpp / 8; + args-pitch = roundup(max(args-pitch, min_pitch), align); return drm_gem_cma_dumb_create(file, dev, args); @@ -125,6 +132,7 @@ static struct drm_framebuffer * rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd2 *mode_cmd) { + struct rcar_du_device *rcdu = dev-dev_private; const struct rcar_du_format_info *format; unsigned int align; @@ -135,7 +143,10 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, return ERR_PTR(-EINVAL); } - align = 16 * format-bpp / 8; + if (rcar_du_has(rcdu, RCAR_DU_FEATURE_ALIGN_128B)) + align = 128; + else + align = 16 * format-bpp / 8; if (mode_cmd-pitches[0] (align - 1) || mode_cmd-pitches[0] = 8192) { -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 20/24] drm/rcar-du: Add support for multiple groups
The R8A7790 DU has 3 CRTCs, split in two groups. Support them. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 25 ++- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 ++ drivers/gpu/drm/rcar-du/rcar_du_drv.h | 6 +++-- drivers/gpu/drm/rcar-du/rcar_du_group.c | 4 +-- drivers/gpu/drm/rcar-du/rcar_du_group.h | 3 +++ drivers/gpu/drm/rcar-du/rcar_du_kms.c | 43 - drivers/gpu/drm/rcar-du/rcar_du_plane.c | 6 +++-- drivers/gpu/drm/rcar-du/rcar_du_regs.h | 4 ++- 8 files changed, 63 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 6a2b959..a340224 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -91,7 +91,6 @@ static void rcar_du_crtc_put(struct rcar_du_crtc *rcrtc) static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) { const struct drm_display_mode *mode = rcrtc-crtc.mode; - struct rcar_du_device *rcdu = rcrtc-group-dev; unsigned long clk; u32 value; u32 div; @@ -101,9 +100,9 @@ static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) div = DIV_ROUND_CLOSEST(clk, mode-clock * 1000); div = clamp(div, 1U, 64U) - 1; - rcar_du_write(rcdu, rcrtc-index ? ESCR2 : ESCR, - ESCR_DCLKSEL_CLKS | div); - rcar_du_write(rcdu, rcrtc-index ? OTAR2 : OTAR, 0); + rcar_du_group_write(rcrtc-group, rcrtc-index % 2 ? ESCR2 : ESCR, + ESCR_DCLKSEL_CLKS | div); + rcar_du_group_write(rcrtc-group, rcrtc-index % 2 ? OTAR2 : OTAR, 0); /* Signal polarities */ value = ((mode-flags DRM_MODE_FLAG_PVSYNC) ? 0 : DSMR_VSL) @@ -143,7 +142,6 @@ void rcar_du_crtc_route_output(struct drm_crtc *crtc, unsigned int output) void rcar_du_crtc_update_planes(struct drm_crtc *crtc) { struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); - struct rcar_du_device *rcdu = rcrtc-group-dev; struct rcar_du_plane *planes[RCAR_DU_NUM_HW_PLANES]; unsigned int num_planes = 0; unsigned int prio = 0; @@ -189,8 +187,8 @@ void rcar_du_crtc_update_planes(struct drm_crtc *crtc) /* Select display timing and dot clock generator 2 for planes associated * with superposition controller 2. */ - if (rcrtc-index) { - u32 value = rcar_du_read(rcdu, DPTSR); + if (rcrtc-index % 2) { + u32 value = rcar_du_group_read(rcrtc-group, DPTSR); /* The DPTSR register is updated when the display controller is * stopped. We thus need to restart the DU. Once again, sorry @@ -200,13 +198,14 @@ void rcar_du_crtc_update_planes(struct drm_crtc *crtc) * occur only if we need to break the pre-association. */ if (value != dptsr) { - rcar_du_write(rcdu, DPTSR, dptsr); + rcar_du_group_write(rcrtc-group, DPTSR, dptsr); if (rcrtc-group-used_crtcs) rcar_du_group_restart(rcrtc-group); } } - rcar_du_write(rcdu, rcrtc-index ? DS2PR : DS1PR, dspr); + rcar_du_group_write(rcrtc-group, rcrtc-index % 2 ? DS2PR : DS1PR, + dspr); } static void rcar_du_crtc_start(struct rcar_du_crtc *rcrtc) @@ -528,6 +527,10 @@ static const struct drm_crtc_funcs crtc_funcs = { int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index) { + static const unsigned int mmio_offsets[] = { + DU0_REG_OFFSET, DU1_REG_OFFSET, DU2_REG_OFFSET + }; + struct rcar_du_device *rcdu = rgrp-dev; struct platform_device *pdev = to_platform_device(rcdu-dev); struct rcar_du_crtc *rcrtc = rcdu-crtcs[index]; @@ -553,10 +556,10 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index) } rcrtc-group = rgrp; - rcrtc-mmio_offset = index ? DISP2_REG_OFFSET : 0; + rcrtc-mmio_offset = mmio_offsets[index]; rcrtc-index = index; rcrtc-dpms = DRM_MODE_DPMS_OFF; - rcrtc-plane = rgrp-planes.planes[index]; + rcrtc-plane = rgrp-planes.planes[index % 2]; rcrtc-plane-crtc = crtc; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index fe93670..98e35aa 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -213,10 +213,12 @@ static int rcar_du_remove(struct platform_device *pdev) static const struct rcar_du_device_info rcar_du_r8a7779_info = { .features = 0, + .num_crtcs = 2, }; static const struct rcar_du_device_info rcar_du_r8a7790_info = { .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_ALIGN_128B
[PATCH 21/24] drm/rcar-du: Add support for DEFR8 register
The R8A7790 DU has a new extended function control register. Support it. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 3 ++- drivers/gpu/drm/rcar-du/rcar_du_drv.h | 1 + drivers/gpu/drm/rcar-du/rcar_du_group.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index 98e35aa..dd1950d 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -217,7 +217,8 @@ static const struct rcar_du_device_info rcar_du_r8a7779_info = { }; static const struct rcar_du_device_info rcar_du_r8a7790_info = { - .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_ALIGN_128B, + .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_ALIGN_128B + | RCAR_DU_FEATURE_DEFR8, .num_crtcs = 3, }; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/rcar-du/rcar_du_drv.h index 160e5eb..70c335f 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h @@ -27,6 +27,7 @@ struct rcar_du_device; #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 0)/* Per-CRTC IRQ and clock */ #define RCAR_DU_FEATURE_ALIGN_128B (1 1)/* Align pitches to 128 bytes */ +#define RCAR_DU_FEATURE_DEFR8 (1 2)/* Has DEFR8 register */ /* * struct rcar_du_device_info - DU model-specific information diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c b/drivers/gpu/drm/rcar-du/rcar_du_group.c index 0eb106e..f3ba0ca 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_group.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c @@ -51,6 +51,8 @@ static void rcar_du_group_setup(struct rcar_du_group *rgrp) rcar_du_group_write(rgrp, DEFR3, DEFR3_CODE | DEFR3_DEFE3); rcar_du_group_write(rgrp, DEFR4, DEFR4_CODE); rcar_du_group_write(rgrp, DEFR5, DEFR5_CODE | DEFR5_DEFE5); + if (rcar_du_has(rgrp-dev, RCAR_DU_FEATURE_DEFR8)) + rcar_du_group_write(rgrp, DEFR8, DEFR8_CODE | DEFR8_DEFE8); /* Use DS1PR and DS2PR to configure planes priorities and connects the * superposition 0 to DU0 pins. DU1 pins will be configured dynamically. -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 22/24] drm/rcar-du: Rework output routing support
Split the output routing specification between SoC-internal data, specified in the rcar_du_device_info structure, and board data, passed through platform data. The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). SoC-internal output routing data specify which output are valid, which CRTCs can be connected to the valid outputs, and the type of in-SoC encoder for the output. Platform data then specifies external encoders and the output they are connected to. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_crtc.c| 6 -- drivers/gpu/drm/rcar-du/rcar_du_crtc.h| 4 +++- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 30 ++ drivers/gpu/drm/rcar-du/rcar_du_drv.h | 16 drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 26 +- drivers/gpu/drm/rcar-du/rcar_du_encoder.h | 5 +++-- drivers/gpu/drm/rcar-du/rcar_du_group.c | 8 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 17 +++-- include/linux/platform_data/rcar-du.h | 17 +++-- 9 files changed, 107 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index a340224..680606e 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -129,14 +129,16 @@ static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) rcar_du_crtc_write(rcrtc, DEWR, mode-hdisplay); } -void rcar_du_crtc_route_output(struct drm_crtc *crtc, unsigned int output) +void rcar_du_crtc_route_output(struct drm_crtc *crtc, + enum rcar_du_output output) { struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc); + struct rcar_du_device *rcdu = rcrtc-group-dev; /* Store the route from the CRTC output to the DU output. The DU will be * configured when starting the CRTC. */ - rcrtc-outputs |= 1 output; + rcrtc-outputs |= BIT(output); } void rcar_du_crtc_update_planes(struct drm_crtc *crtc) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h index 542a7fe..39a983d 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h @@ -15,6 +15,7 @@ #define __RCAR_DU_CRTC_H__ #include linux/mutex.h +#include linux/platform_data/rcar-du.h #include drm/drmP.h #include drm/drm_crtc.h @@ -45,7 +46,8 @@ void rcar_du_crtc_cancel_page_flip(struct rcar_du_crtc *rcrtc, void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc); void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc); -void rcar_du_crtc_route_output(struct drm_crtc *crtc, unsigned int output); +void rcar_du_crtc_route_output(struct drm_crtc *crtc, + enum rcar_du_output output); void rcar_du_crtc_update_planes(struct drm_crtc *crtc); #endif /* __RCAR_DU_CRTC_H__ */ diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index dd1950d..28654e7 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -214,12 +214,42 @@ static int rcar_du_remove(struct platform_device *pdev) static const struct rcar_du_device_info rcar_du_r8a7779_info = { .features = 0, .num_crtcs = 2, + .routes = { + /* R8A7779 has two RGB outputs and one (currently unsupported) +* TCON output. +*/ + [RCAR_DU_OUTPUT_DPAD0] = { + .possible_crtcs = BIT(0), + .encoder_type = DRM_MODE_ENCODER_NONE, + }, + [RCAR_DU_OUTPUT_DPAD1] = { + .possible_crtcs = BIT(1) | BIT(0), + .encoder_type = DRM_MODE_ENCODER_NONE, + }, + }, }; static const struct rcar_du_device_info rcar_du_r8a7790_info = { .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_ALIGN_128B | RCAR_DU_FEATURE_DEFR8, .num_crtcs = 3, + .routes = { + /* R8A7790 has one RGB output, two LVDS outputs and one +* (currently unsupported) TCON output. +*/ + [RCAR_DU_OUTPUT_DPAD0] = { + .possible_crtcs = BIT(2) | BIT(1) | BIT(0), + .encoder_type = DRM_MODE_ENCODER_NONE, + }, + [RCAR_DU_OUTPUT_LVDS0] = { + .possible_crtcs = BIT(0), + .encoder_type = DRM_MODE_ENCODER_LVDS, + }, + [RCAR_DU_OUTPUT_LVDS1] = { + .possible_crtcs = BIT(2) | BIT(1), + .encoder_type = DRM_MODE_ENCODER_LVDS, + }, + }, }; static const struct platform_device_id rcar_du_id_table[] = { diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/rcar-du
[PATCH 23/24] drm/rcar-du: Configure RGB output routing to DPAD0
The R8A7790 DU variant has a single RGB output called DPAD0 that can be fed with the output of DU0, DU1 or DU2. Making the routing configurable. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 5 drivers/gpu/drm/rcar-du/rcar_du_drv.h | 2 ++ drivers/gpu/drm/rcar-du/rcar_du_group.c | 45 ++--- drivers/gpu/drm/rcar-du/rcar_du_group.h | 2 +- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 680606e..245800d 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -139,6 +139,11 @@ void rcar_du_crtc_route_output(struct drm_crtc *crtc, * configured when starting the CRTC. */ rcrtc-outputs |= BIT(output); + + /* Store RGB routing to DPAD0 for R8A7790. */ + if (rcar_du_has(rcdu, RCAR_DU_FEATURE_DEFR8) + output == RCAR_DU_OUTPUT_DPAD0) + rcdu-dpad0_source = rcrtc-index; } void rcar_du_crtc_update_planes(struct drm_crtc *crtc) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/rcar-du/rcar_du_drv.h index d5243f4..924f5e0 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h @@ -68,6 +68,8 @@ struct rcar_du_device { unsigned int num_crtcs; struct rcar_du_group groups[2]; + + unsigned int dpad0_source; }; static inline bool rcar_du_has(struct rcar_du_device *rcdu, diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c b/drivers/gpu/drm/rcar-du/rcar_du_group.c index 9df6fb6..eb53cd9 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_group.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c @@ -27,6 +27,7 @@ * counterpart in the DU documentation, that models those semi-global resources. */ +#include linux/clk.h #include linux/io.h #include rcar_du_drv.h @@ -43,6 +44,22 @@ void rcar_du_group_write(struct rcar_du_group *rgrp, u32 reg, u32 data) rcar_du_write(rgrp-dev, rgrp-mmio_offset + reg, data); } +static void rcar_du_group_setup_defr8(struct rcar_du_group *rgrp) +{ + u32 defr8 = DEFR8_CODE | DEFR8_DEFE8; + + if (!rcar_du_has(rgrp-dev, RCAR_DU_FEATURE_DEFR8)) + return; + + /* The DEFR8 register for the first group also controls RGB output +* routing to DPAD0 +*/ + if (rgrp-index == 0) + defr8 |= DEFR8_DRGBS_DU(rgrp-dev-dpad0_source); + + rcar_du_group_write(rgrp, DEFR8, defr8); +} + static void rcar_du_group_setup(struct rcar_du_group *rgrp) { /* Enable extended features */ @@ -51,8 +68,8 @@ static void rcar_du_group_setup(struct rcar_du_group *rgrp) rcar_du_group_write(rgrp, DEFR3, DEFR3_CODE | DEFR3_DEFE3); rcar_du_group_write(rgrp, DEFR4, DEFR4_CODE); rcar_du_group_write(rgrp, DEFR5, DEFR5_CODE | DEFR5_DEFE5); - if (rcar_du_has(rgrp-dev, RCAR_DU_FEATURE_DEFR8)) - rcar_du_group_write(rgrp, DEFR8, DEFR8_CODE | DEFR8_DEFE8); + + rcar_du_group_setup_defr8(rgrp); /* Use DS1PR and DS2PR to configure planes priorities and connects the * superposition 0 to DU0 pins. DU1 pins will be configured dynamically. @@ -128,7 +145,27 @@ void rcar_du_group_restart(struct rcar_du_group *rgrp) __rcar_du_group_start_stop(rgrp, true); } -void rcar_du_group_set_routing(struct rcar_du_group *rgrp) +static int rcar_du_set_dpad0_routing(struct rcar_du_device *rcdu) +{ + int ret; + + /* RGB output routing to DPAD0 is configured in the DEFR8 register of +* the first group. As this function can be called with the DU0 and DU1 +* CRTCs disabled, we need to enable the first group clock before +* accessing the register. +*/ + ret = clk_prepare_enable(rcdu-crtcs[0].clock); + if (ret 0) + return ret; + + rcar_du_group_setup_defr8(rcdu-groups[0]); + + clk_disable_unprepare(rcdu-crtcs[0].clock); + + return 0; +} + +int rcar_du_group_set_routing(struct rcar_du_group *rgrp) { struct rcar_du_crtc *crtc0 = rgrp-dev-crtcs[rgrp-index * 2]; u32 dorcr = rcar_du_group_read(rgrp, DORCR); @@ -145,4 +182,6 @@ void rcar_du_group_set_routing(struct rcar_du_group *rgrp) dorcr |= DORCR_PG2T | DORCR_DK2S | DORCR_PG2D_DS2; rcar_du_group_write(rgrp, DORCR, dorcr); + + return rcar_du_set_dpad0_routing(rgrp-dev); } diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.h b/drivers/gpu/drm/rcar-du/rcar_du_group.h index 4487e83..5025930 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_group.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_group.h @@ -45,6 +45,6 @@ int rcar_du_group_get(struct rcar_du_group *rgrp); void rcar_du_group_put(struct rcar_du_group *rgrp); void rcar_du_group_start_stop(struct rcar_du_group *rgrp, bool start); void rcar_du_group_restart(struct
[PATCH 24/24] drm/rcar-du: Add internal LVDS encoder support
The R8A7790 includes two internal LVDS encoders. Support them in the DU driver. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/Kconfig | 7 ++ drivers/gpu/drm/rcar-du/Makefile | 4 +- drivers/gpu/drm/rcar-du/rcar_du_crtc.c| 2 - drivers/gpu/drm/rcar-du/rcar_du_crtc.h| 2 + drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 + drivers/gpu/drm/rcar-du/rcar_du_drv.h | 4 + drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 38 ++ drivers/gpu/drm/rcar-du/rcar_du_encoder.h | 2 + drivers/gpu/drm/rcar-du/rcar_du_kms.c | 5 + drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 194 ++ drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h | 46 +++ drivers/gpu/drm/rcar-du/rcar_lvds_regs.h | 69 +++ 12 files changed, 372 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h create mode 100644 drivers/gpu/drm/rcar-du/rcar_lvds_regs.h diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig index 72887df..c590cd9 100644 --- a/drivers/gpu/drm/rcar-du/Kconfig +++ b/drivers/gpu/drm/rcar-du/Kconfig @@ -7,3 +7,10 @@ config DRM_RCAR_DU help Choose this option if you have an R-Car chipset. If M is selected the module will be called rcar-du-drm. + +config DRM_RCAR_LVDS + bool R-Car DU LVDS Encoder Support + depends on DRM_RCAR_DU + help + Enable support the R-Car Display Unit embedded LVDS encoders + (currently only on R8A7790). diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile index b9b5e66..12b8d44 100644 --- a/drivers/gpu/drm/rcar-du/Makefile +++ b/drivers/gpu/drm/rcar-du/Makefile @@ -7,4 +7,6 @@ rcar-du-drm-y := rcar_du_crtc.o \ rcar_du_plane.o \ rcar_du_vgacon.o -obj-$(CONFIG_DRM_RCAR_DU) += rcar-du-drm.o +rcar-du-drm-$(CONFIG_DRM_RCAR_LVDS)+= rcar_du_lvdsenc.o + +obj-$(CONFIG_DRM_RCAR_DU) += rcar-du-drm.o diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c index 245800d..33df7a5 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c @@ -26,8 +26,6 @@ #include rcar_du_plane.h #include rcar_du_regs.h -#define to_rcar_crtc(c)container_of(c, struct rcar_du_crtc, crtc) - static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg) { struct rcar_du_device *rcdu = rcrtc-group-dev; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h index 39a983d..43e7575 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h @@ -39,6 +39,8 @@ struct rcar_du_crtc { struct rcar_du_plane *plane; }; +#define to_rcar_crtc(c)container_of(c, struct rcar_du_crtc, crtc) + int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index); void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable); void rcar_du_crtc_cancel_page_flip(struct rcar_du_crtc *rcrtc, diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index 28654e7..53cc827 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -227,6 +227,7 @@ static const struct rcar_du_device_info rcar_du_r8a7779_info = { .encoder_type = DRM_MODE_ENCODER_NONE, }, }, + .num_lvds = 0, }; static const struct rcar_du_device_info rcar_du_r8a7790_info = { @@ -250,6 +251,7 @@ static const struct rcar_du_device_info rcar_du_r8a7790_info = { .encoder_type = DRM_MODE_ENCODER_LVDS, }, }, + .num_lvds = 2, }; static const struct platform_device_id rcar_du_id_table[] = { diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/rcar-du/rcar_du_drv.h index 924f5e0..050d71c 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h @@ -24,6 +24,7 @@ struct clk; struct device; struct drm_device; struct rcar_du_device; +struct rcar_du_lvdsenc; #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 0)/* Per-CRTC IRQ and clock */ #define RCAR_DU_FEATURE_ALIGN_128B (1 1)/* Align pitches to 128 bytes */ @@ -48,11 +49,13 @@ struct rcar_du_output_routing { * @features: device features (RCAR_DU_FEATURE_*) * @num_crtcs: total number of CRTCs * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*) + * @num_lvds: number of internal LVDS encoders */ struct rcar_du_device_info { unsigned int features; unsigned int num_crtcs; struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX]; + unsigned int num_lvds; }; struct rcar_du_device { @@ -70,6 +73,7 @@ struct rcar_du_device
Re: [PATCH v2] drm/gem: add mutex lock when using drm_gem_mmap_obj
Hi, On Thursday 27 June 2013 08:39:58 Seung-Woo Kim wrote: From: YoungJun Cho yj44@samsung.com The drm_gem_mmap_obj() has to be protected with dev-struct_mutex, but some caller functions do not. So it adds mutex lock to missing callers and adds assertion to check whether drm_gem_mmap_obj() is called with mutex lock or not. Signed-off-by: YoungJun Cho yj44@samsung.com Signed-off-by: Seung-Woo Kim sw0312@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com CC: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com CC: Rob Clark robdcl...@gmail.com Thanks for the patch. Reviewed-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- This patch is based on drm-next branch. Changes since v1: - Use lockdep_assert_held() instead of mutex_is_locked() as Maarten commented - Fix commit message about assertion drivers/gpu/drm/drm_gem.c |4 drivers/gpu/drm/drm_gem_cma_helper.c |3 +++ drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c |3 +++ 3 files changed, 10 insertions(+) diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 4321713..34c0be7 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -661,6 +661,8 @@ EXPORT_SYMBOL(drm_gem_vm_close); * the GEM object is not looked up based on its fake offset. To implement the * DRM mmap operation, drivers should use the drm_gem_mmap() function. * + * NOTE: This function has to be protected with dev-struct_mutex + * * Return 0 or success or -EINVAL if the object size is smaller than the VMA * size, or if no gem_vm_ops are provided. */ @@ -669,6 +671,8 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size, { struct drm_device *dev = obj-dev; + lockdep_assert_held(dev-struct_mutex); + /* Check for valid size. */ if (obj_size vma-vm_end - vma-vm_start) return -EINVAL; diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c index 9efabce..ce06397 100644 --- a/drivers/gpu/drm/drm_gem_cma_helper.c +++ b/drivers/gpu/drm/drm_gem_cma_helper.c @@ -487,9 +487,12 @@ static int drm_gem_cma_dmabuf_mmap(struct dma_buf *dmabuf, { struct drm_gem_cma_object *cma_obj = dmabuf-priv; struct drm_gem_object *gem_obj = cma_obj-base; + struct drm_device *dev = gem_obj-dev; int ret; + mutex_lock(dev-struct_mutex); ret = drm_gem_mmap_obj(gem_obj, gem_obj-size, vma); + mutex_unlock(dev-struct_mutex); if (ret 0) return ret; diff --git a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c index 3256693..4fcca8d 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c +++ b/drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c @@ -140,12 +140,15 @@ static int omap_gem_dmabuf_mmap(struct dma_buf *buffer, struct vm_area_struct *vma) { struct drm_gem_object *obj = buffer-priv; + struct drm_device *dev = obj-dev; int ret = 0; if (WARN_ON(!obj-filp)) return -EINVAL; + mutex_lock(dev-struct_mutex); ret = drm_gem_mmap_obj(obj, omap_gem_mmap_size(obj), vma); + mutex_unlock(dev-struct_mutex); if (ret 0) return ret; -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 02/24] drm/rcar-du: Use devm_ioremap_resource()
Hi Sergei, On Thursday 27 June 2013 17:04:45 Sergei Shtylyov wrote: On 27-06-2013 13:49, Laurent Pinchart wrote: Replace the devm_request_mem_region() and devm_ioremap_nocache() calls with devm_ioremap_resource(). Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 20 ++-- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index 003b34e..24ab0ca 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c [...] @@ -129,24 +128,9 @@ static int rcar_du_load(struct drm_device *dev, unsigned long flags) /* I/O resources and clocks */ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); [...] + rcdu-mmio = devm_ioremap_resource(pdev-dev, mem); + if (IS_ERR(rcdu-mmio)) return -ENOMEM; You should return PTR_ERR(rcdu-mmio). Good point, I'll fix that. Thank you. -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [ANNOUNCE] libdrm 2.4.46
Hi Dave, On Tuesday 02 July 2013 18:22:01 Dave Airlie wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Release because I want the cursor ioctls released, also haswell and radeon ids. Any chance to get the [PATCH v6 00/23] modetest enhancements series included in the next release ? -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 0/6] DRM: Unified VMA Offset Manager
Hi David, On Monday 01 July 2013 20:32:57 David Herrmann wrote: Hi I picked up the initial work from Dave [1], fixed several bugs, rewrote the drm_mm node handling and adjusted the different drivers. The series tries to replace the VMA-offset managers from GEM and TTM with a single unified implementation. It uses the TTM RBTree idea to allow sub-mappings (which wouldn't be feasible with hashtables). Nice work, thank you. Could you please also update Documentation/DocBook/drm.tmpl ? Changes to Dave's v1: * Fixed a ref-count bug in TTM during object lookup * Use embedded drm_mm_node objects to avoid allocations * Document drm_vma_* API * Reviewed TTM locking * Fixed all new drivers * Use node-vm_pages instead of obj-size for GEM size calculations Notes: * Tested on nouveau only! I will try to test i915 this week. However, the gem changes seem pretty trivial. * I couldn't even compile-test the ARM drivers. However, the omapdrm diffs are the only changes that are non-trivial. Is there any ongoing work to remove the arch-deps in DRM drivers? * _DRM_GEM is no longer used, but I guess we need to keep it for backwards compat? * If we replace node_list in drm_mm with an rbtree, we can drop it from drm_vma_offset_manager completely. However, I wanted to avoid heavy drm_mm changes and left this for follow up patches. * This is currently based on linux-3.10 from today. Next series will be rebased on drm-next/linux-next, but the current -next trees continously break my machines.. But the only changes should be to fix additional drivers. I didn't see any other things to fix for drm-next. Another series, which I will send later, adds struct file lists for each drm-vma-offset so we can get access control over gem objects. Also, I have an experimental series to remove the allocation helpers in drm_mm and let drivers embed drm_mm_node instead. Lets see how that works out. Comments welcome! Cheers David [1]: http://cgit.freedesktop.org/~airlied/linux/log/?h=drm-vma-manager David Herrmann (6): drm: make drm_mm_init() return void drm: mm: add drm_mm_node_linked() helper drm: add unified vma offset manager drm: gem: convert to new unified vma manager drm: ttm: convert to unified vma offset manager drm: provide generic drm_vma_node_unmap() helper drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/ast/ast_main.c | 2 +- drivers/gpu/drm/cirrus/cirrus_main.c | 2 +- drivers/gpu/drm/drm_gem.c | 93 ++-- drivers/gpu/drm/drm_gem_cma_helper.c | 9 +- drivers/gpu/drm/drm_mm.c | 5 +- drivers/gpu/drm/drm_vma_manager.c | 224 ++ drivers/gpu/drm/exynos/exynos_drm_gem.c| 7 +- drivers/gpu/drm/gma500/gem.c | 8 +- drivers/gpu/drm/i915/i915_gem.c| 13 +- drivers/gpu/drm/mgag200/mgag200_main.c | 2 +- drivers/gpu/drm/nouveau/nouveau_display.c | 2 +- drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +- drivers/gpu/drm/omapdrm/omap_gem.c | 11 +- drivers/gpu/drm/omapdrm/omap_gem_helpers.c | 49 +-- drivers/gpu/drm/qxl/qxl_object.h | 2 +- drivers/gpu/drm/qxl/qxl_release.c | 2 +- drivers/gpu/drm/radeon/radeon_object.h | 5 +- drivers/gpu/drm/ttm/ttm_bo.c | 82 ++- drivers/gpu/drm/ttm/ttm_bo_manager.c | 8 +- drivers/gpu/drm/ttm/ttm_bo_util.c | 3 +- drivers/gpu/drm/ttm/ttm_bo_vm.c| 81 --- drivers/gpu/drm/udl/udl_gem.c | 6 +- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 4 +- include/drm/drmP.h | 7 +- include/drm/drm_mm.h | 11 +- include/drm/drm_vma_manager.h | 122 include/drm/ttm/ttm_bo_api.h | 15 +- include/drm/ttm/ttm_bo_driver.h| 7 +- include/uapi/drm/drm.h | 2 +- 30 files changed, 464 insertions(+), 324 deletions(-) create mode 100644 drivers/gpu/drm/drm_vma_manager.c create mode 100644 include/drm/drm_vma_manager.h -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [ANNOUNCE] libdrm 2.4.46
Hi Dave, On Wednesday 03 July 2013 10:17:34 Dave Airlie wrote: On Wed, Jul 3, 2013 at 9:55 AM, Laurent Pinchart wrote: On Tuesday 02 July 2013 18:22:01 Dave Airlie wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Release because I want the cursor ioctls released, also haswell and radeon ids. Any chance to get the [PATCH v6 00/23] modetest enhancements series included in the next release ? Do you not have commit access? No I don't. if not I'd advise getting it, libdrm is maintained by everyone collectively and gets released when someone sees the need for something in git. I certainly don't pull patches in from others to it very often, and modetest I generally blame on jbarnes. How do I get commit access ? -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 0/3] drm/cma: use prime helpers instead GEM CMA specific dma_buf functionality
Hi Joonyoung, Thank you for the patches. On Friday 28 June 2013 14:24:43 Joonyoung Shim wrote: Hello, This is the second version patchset. GEM CMA supports dma_buf but it needs GEM CMA specific functionality for dma_buf. We can use prime helpers for dma_buf by commit 89177644a7b6306e6084a89eab7e290f4bfef397 drm: add prime helpers, so this patchset is to replace from using GEM CMA specific functions to using prime helpers. To Laurent, It is merged a patch to cache mapping from DRM Prime, can this patchset get your ack? There you go (and sorry for the late reply) Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com By the way, between the initial version of the GEM CMA PRIME patch and the version that got merged in v3.10, commit 011c2282c74db120f01a8414edc66c3f217f5511 (drm: prime: fix refcounting on the dmabuf import error path) was introduced. The GEM CMA PRIME code in v3.10 thus has a refcounting bug :-( Should this patch set go to -stable, or should we cook up a special fix ? Changes from v1: - rebased from drm-next branch of git://people.freedesktop.org/~airlied/linux - fix to check whether gem_prime_mmap field is NULL from drm: add mmap function to prime helpers commit Joonyoung Shim (3): drm: add mmap function to prime helpers drm/cma: add low-level hook functions to use prime helpers drm/cma: remove GEM CMA specific dma_buf functionality drivers/gpu/drm/drm_gem_cma_helper.c | 293 --- drivers/gpu/drm/drm_prime.c | 8 +- include/drm/drmP.h | 2 + include/drm/drm_gem_cma_helper.h | 13 +- 4 files changed, 60 insertions(+), 256 deletions(-) -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 0/2] R-Car DU DRM fixes for v3.11
Hello, Here are two small fixes to the R-Car DU DRM driver. They have previously been posted as part of the larger R-Car DU DRM support for R8A7790 series, and Daniel Vetter rightfully noticed that they should be applied to v3.11. Laurent Pinchart (2): drm/rcar-du: Don't ignore rcar_du_crtc_create() return value drm/rcar-du: Fix buffer pitch alignment drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 26 +++--- drivers/gpu/drm/rcar-du/rcar_du_kms.h | 3 +++ 3 files changed, 27 insertions(+), 4 deletions(-) -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 1/2] drm/rcar-du: Don't ignore rcar_du_crtc_create() return value
Handle error cases correctly. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 9c63f39..06cacf6 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -191,8 +191,11 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu) if (ret 0) return ret; - for (i = 0; i ARRAY_SIZE(rcdu-crtcs); ++i) - rcar_du_crtc_create(rcdu, i); + for (i = 0; i ARRAY_SIZE(rcdu-crtcs); ++i) { + ret = rcar_du_crtc_create(rcdu, i); + if (ret 0) + return ret; + } rcdu-used_crtcs = 0; rcdu-num_crtcs = i; -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 2/2] drm/rcar-du: Fix buffer pitch alignment
The DU requires a 16 pixels pitch alignement. Make sure dumb buffers are allocated with the correct pitch, and validate the pitch when creating frame buffers. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 19 ++- drivers/gpu/drm/rcar-du/rcar_du_kms.h | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index 003b34e..ff82877 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -251,7 +251,7 @@ static struct drm_driver rcar_du_driver = { .prime_fd_to_handle = drm_gem_prime_fd_to_handle, .gem_prime_import = drm_gem_cma_dmabuf_import, .gem_prime_export = drm_gem_cma_dmabuf_export, - .dumb_create= drm_gem_cma_dumb_create, + .dumb_create= rcar_du_dumb_create, .dumb_map_offset= drm_gem_cma_dumb_map_offset, .dumb_destroy = drm_gem_cma_dumb_destroy, .fops = rcar_du_fops, diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 06cacf6..d30c2e2 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -138,11 +138,25 @@ void rcar_du_encoder_mode_commit(struct drm_encoder *encoder) * Frame buffer */ +int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, + struct drm_mode_create_dumb *args) +{ + unsigned int min_pitch = DIV_ROUND_UP(args-width * args-bpp, 8); + unsigned int align; + + /* The pitch must be aligned to a 16 pixels boundary. */ + align = 16 * args-bpp / 8; + args-pitch = roundup(max(args-pitch, min_pitch), align); + + return drm_gem_cma_dumb_create(file, dev, args); +} + static struct drm_framebuffer * rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd2 *mode_cmd) { const struct rcar_du_format_info *format; + unsigned int align; format = rcar_du_format_info(mode_cmd-pixel_format); if (format == NULL) { @@ -151,7 +165,10 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, return ERR_PTR(-EINVAL); } - if (mode_cmd-pitches[0] 15 || mode_cmd-pitches[0] = 8192) { + align = 16 * format-bpp / 8; + + if (mode_cmd-pitches[0] (align - 1) || + mode_cmd-pitches[0] = 8192) { dev_dbg(dev-dev, invalid pitch value %u\n, mode_cmd-pitches[0]); return ERR_PTR(-EINVAL); diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.h b/drivers/gpu/drm/rcar-du/rcar_du_kms.h index e4d8db0..dba4722 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.h @@ -56,4 +56,7 @@ void rcar_du_encoder_mode_commit(struct drm_encoder *encoder); int rcar_du_modeset_init(struct rcar_du_device *rcdu); +int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, + struct drm_mode_create_dumb *args); + #endif /* __RCAR_DU_KMS_H__ */ -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm: cma: fix refcounting on the dmabuf import error path
Hi Joonyoung, Thank you for the patch. On Friday 05 July 2013 15:32:35 Joonyoung Shim wrote: From drm gem CMA helper, it wasn't fixed dma_buf refcount problem fixed by commit 011c228. This patch solves it. Please add a Cc:sta...@vger.kernel.org here. Signed-off-by: Joonyoung Shim jy0922.s...@samsung.com Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- drivers/gpu/drm/drm_gem_cma_helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_gem_cma_helper.c b/drivers/gpu/drm/drm_gem_cma_helper.c index ce06397..3f3a12b 100644 --- a/drivers/gpu/drm/drm_gem_cma_helper.c +++ b/drivers/gpu/drm/drm_gem_cma_helper.c @@ -554,7 +554,6 @@ struct drm_gem_object *drm_gem_cma_dmabuf_import(struct drm_device *drm, * refcount on gem itself instead of f_count of dmabuf. */ drm_gem_object_reference(obj); - dma_buf_put(dma_buf); return obj; } } @@ -573,6 +572,8 @@ struct drm_gem_object *drm_gem_cma_dmabuf_import(struct drm_device *drm, goto error_gem_free; } + get_dma_buf(dma_buf); + As a side note, you have probably placed the get_dma_buf() call here to mimic the drm_prime.c code, but would there be anything wrong by placing it right before returning the GEM object ? The dma_buf_put() call could then be removed from the error path. sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL); if (IS_ERR_OR_NULL(sgt)) { ret = sgt ? PTR_ERR(sgt) : -ENOMEM; @@ -597,6 +598,7 @@ error_buf_unmap: dma_buf_unmap_attachment(attach, sgt, DMA_BIDIRECTIONAL); error_buf_detach: dma_buf_detach(dma_buf, attach); + dma_buf_put(dma_buf); error_gem_free: drm_gem_cma_free_object(cma_obj-base); return ERR_PTR(ret); -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 0/2] R-Car DU DRM fixes for v3.11
Hi Dave, On Thursday 04 July 2013 20:05:49 Laurent Pinchart wrote: Hello, Here are two small fixes to the R-Car DU DRM driver. They have previously been posted as part of the larger R-Car DU DRM support for R8A7790 series, and Daniel Vetter rightfully noticed that they should be applied to v3.11. Given that your pull request for v3.11 hasn't been sent yet due to a dependency on fbdev, could you consider taking these two fixes in for v3.11 ? Laurent Pinchart (2): drm/rcar-du: Don't ignore rcar_du_crtc_create() return value drm/rcar-du: Fix buffer pitch alignment drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 26 +++--- drivers/gpu/drm/rcar-du/rcar_du_kms.h | 3 +++ 3 files changed, 27 insertions(+), 4 deletions(-) -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 0/3] drm/cma: use prime helpers instead GEM CMA specific dma_buf functionality
Hi Joonyoung, On Friday 05 July 2013 15:30:25 Joonyoung Shim wrote: On 07/05/2013 02:38 PM, Dave Airlie wrote: On Thu, Jul 4, 2013 at 5:14 PM, Joonyoung Shim wrote: On 07/04/2013 07:11 AM, Laurent Pinchart wrote: On Friday 28 June 2013 14:24:43 Joonyoung Shim wrote: Hello, This is the second version patchset. GEM CMA supports dma_buf but it needs GEM CMA specific functionality for dma_buf. We can use prime helpers for dma_buf by commit 89177644a7b6306e6084a89eab7e290f4bfef397 drm: add prime helpers, so this patchset is to replace from using GEM CMA specific functions to using prime helpers. To Laurent, It is merged a patch to cache mapping from DRM Prime, can this patchset get your ack? There you go (and sorry for the late reply) Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com By the way, between the initial version of the GEM CMA PRIME patch and the version that got merged in v3.10, commit 011c2282c74db120f01a8414edc66c3f217f5511 (drm: prime: fix refcounting on the dmabuf import error path) was introduced. The GEM CMA PRIME code in v3.10 thus has a refcounting bug :-( Should this patch set go to -stable, or should we cook up a special fix ? I'm not sure it's better to choose which way. Dave, how we should do about that problem? I think a special fix for stable once we get these merged to Linus. OK, i will post a patch for a special fix. Thank you. We need to fix the problem for v3.11 as well, by applying either this set or the fix you have just sent. I have no strong preference regarding which patches to pick. -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm/rcar-du: Add missing dependency on CMA
Hi Mark, Thanks for the patch. On Wednesday 10 July 2013 11:52:14 Mark Brown wrote: From: Mark Brown broo...@linaro.org The driver uses CMA APIs so won't link if CMA is not being built. Signed-off-by: Mark Brown broo...@linaro.org --- drivers/gpu/drm/rcar-du/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rcar-du/Kconfig b/drivers/gpu/drm/rcar-du/Kconfig index 72887df..e75575a 100644 --- a/drivers/gpu/drm/rcar-du/Kconfig +++ b/drivers/gpu/drm/rcar-du/Kconfig @@ -1,6 +1,6 @@ config DRM_RCAR_DU tristate DRM Support for R-Car Display Unit - depends on DRM ARM + depends on DRM ARM CMA select DRM_KMS_HELPER select DRM_KMS_CMA_HELPER select DRM_GEM_CMA_HELPER Shouldn't we instead make DRM_GEM_CMA_HELPER depend on CMA ? -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm/rcar-du: Add missing dependency on CMA
On Wednesday 10 July 2013 12:07:24 Mark Brown wrote: On Wed, Jul 10, 2013 at 12:54:40PM +0200, Laurent Pinchart wrote: On Wednesday 10 July 2013 11:52:14 Mark Brown wrote: config DRM_RCAR_DU tristate DRM Support for R-Car Display Unit - depends on DRM ARM + depends on DRM ARM CMA select DRM_KMS_HELPER select DRM_KMS_CMA_HELPER select DRM_GEM_CMA_HELPER Shouldn't we instead make DRM_GEM_CMA_HELPER depend on CMA ? Sadly select doesn't do the right thing with dependencies - it just ignores them. OK, my bad. On the other hand, thinking a bit more about this, the DU driver doesn't use the CMA API directly, as there's no CMA API exposed to drivers :-) I've successfully built the driver with CONFIG_CMA disabled. Could you please share the .config that resulted in a link error ? -- Regards, Laurent Pinchart signature.asc Description: This is a digitally signed message part. ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm/prime: remove cargo-cult locking from map_sg helper
Hi Daniel, On Wednesday 10 July 2013 13:54:33 Daniel Vetter wrote: I've checked both implementations (radeon/nouveau) and they both grab the page array from ttm simply by dereferencing it and then wrapping it up with drm_prime_pages_to_sg in the callback and map it with dma_map_sg (in the helper). Have you checked drm_gem_cma_prime_get_sg_table (in drm_gem_cma_helper.c) as well ? Only the grabbing of the underlying page array is anything we need to be concerned about, and either those pages are pinned independently, or we're screwed no matter what. And indeed, nouveau/radeon pin the backing storage in their attach/detach functions. The only thing we might claim it does is prevent concurrent mapping of dma_buf attachments. But a) that's not allowed and b) the current code is racy already since it checks whether the sg mapping exists _before_ grabbing the lock. So the dev-struct_mutex locking here does absolutely nothing useful, but only distracts. Remove it. This should also help Maarten's work to eventually pin the backing storage more dynamically by preventing locking inversions around dev-struct_mutex. Cc: Maarten Lankhorst maarten.lankho...@canonical.com Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch --- drivers/gpu/drm/drm_prime.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 85e450e..64a99b3 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -167,8 +167,6 @@ static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, if (WARN_ON(prime_attach-dir != DMA_NONE)) return ERR_PTR(-EBUSY); - mutex_lock(obj-dev-struct_mutex); - sgt = obj-dev-driver-gem_prime_get_sg_table(obj); if (!IS_ERR(sgt)) { @@ -182,7 +180,6 @@ static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, } } - mutex_unlock(obj-dev-struct_mutex); return sgt; } -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 0/2] GEM CMA PRIME fixes for v3.11
Hi Dave, These two patches fix compilation breakages in drm-next due to the removal of drm_gem_cma_dmabuf_import() and drm_gem_cma_dmabuf_export() without updating the existing users (I don't blame anyone here, the patch that removed those functions and the patches that made use of them were merged at the same time). Laurent Pinchart (2): drm/rcar-du: Use the GEM PRIME helpers drm/shmobile: Use the GEM PRIME helpers drivers/gpu/drm/rcar-du/rcar_du_drv.c| 9 +++-- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 9 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 1/2] drm/rcar-du: Use the GEM PRIME helpers
The GEM CMA PRIME import/export helpers have been removed in favor of generic GEM PRIME helpers with GEM CMA low-level operations. Fix the driver accordingly. Reported-by: Mark Brown broo...@sirena.org.uk Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index a4c2007..38a8b52 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -152,8 +152,13 @@ static struct drm_driver rcar_du_driver = { .gem_vm_ops = drm_gem_cma_vm_ops, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, - .gem_prime_import = drm_gem_cma_dmabuf_import, - .gem_prime_export = drm_gem_cma_dmabuf_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_export = drm_gem_prime_export, + .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, + .gem_prime_vmap = drm_gem_cma_prime_vmap, + .gem_prime_vunmap = drm_gem_cma_prime_vunmap, + .gem_prime_mmap = drm_gem_cma_prime_mmap, .dumb_create= rcar_du_dumb_create, .dumb_map_offset= drm_gem_cma_dumb_map_offset, .dumb_destroy = drm_gem_cma_dumb_destroy, -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 2/2] drm/shmobile: Use the GEM PRIME helpers
The GEM CMA PRIME import/export helpers have been removed in favor of generic GEM PRIME helpers with GEM CMA low-level operations. Fix the driver accordingly. Reported-by: Mark Brown broo...@sirena.org.uk Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c index edc1018..5f83f9a 100644 --- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c +++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c @@ -276,8 +276,13 @@ static struct drm_driver shmob_drm_driver = { .gem_vm_ops = drm_gem_cma_vm_ops, .prime_handle_to_fd = drm_gem_prime_handle_to_fd, .prime_fd_to_handle = drm_gem_prime_fd_to_handle, - .gem_prime_import = drm_gem_cma_dmabuf_import, - .gem_prime_export = drm_gem_cma_dmabuf_export, + .gem_prime_import = drm_gem_prime_import, + .gem_prime_export = drm_gem_prime_export, + .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, + .gem_prime_vmap = drm_gem_cma_prime_vmap, + .gem_prime_vunmap = drm_gem_cma_prime_vunmap, + .gem_prime_mmap = drm_gem_cma_prime_mmap, .dumb_create= drm_gem_cma_dumb_create, .dumb_map_offset= drm_gem_cma_dumb_map_offset, .dumb_destroy = drm_gem_cma_dumb_destroy, -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm: remove FASYNC support
Hi Daniel, Thank you for the patch. On Wednesday 10 July 2013 17:25:04 Daniel Vetter wrote: So I've stumbled over drm_fasync and wondered what it does. Digging that up is quite a story. First I've had to read up on what this does and ended up being rather bewildered why peopled loved signals so much back in the days that they've created SIGIO just for that ... Then I wondered how this ever works, and what that strange No-op. comment right above it should mean. After all calling the core fasync helper is pretty obviously not a noop. After reading through the kernels FASYNC implementation I've noticed that signals are only sent out to the processes attached with FASYNC by calling kill_fasync. No merged drm driver has ever done that. After more digging I've found out that the only driver that ever used this is the so called GAMMA driver. I've frankly never heard of such a gpu brand ever before. Now FASYNC seems to not have been the only bad thing with that driver, since Dave Airlie removed it from the drm driver with prejudice: commit 1430163b4bbf7b00367ea1066c1c5fe85dbeefed Author: Dave Airlie airl...@linux.ie Date: Sun Aug 29 12:04:35 2004 + Drop GAMMA DRM from a great height ... Long story short, the drm fasync support seems to be doing absolutely nothing. And the only user of it was never merged into the upstream kernel. And we don't need any fops-fasync callback since the fcntl implementation in the kernel already implements the noop case correctly. So stop this particular cargo-cult and rip it all out. v2: Kill drm_fasync assignments in rcar (newly added) and imx drivers (somehow I've missed that one in staging). Also drop the reference in the drm DocBook. ARM compile-fail reported by Rob Clark. v3: Move the removal of dev-buf_asnyc assignment in drm_setup to this patch here. v4: Actually git add ... tsk. Cc: Dave Airlie airl...@linux.ie Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com Cc: Rob Clark robdcl...@gmail.com Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- Documentation/DocBook/drm.tmpl | 1 - drivers/gpu/drm/ast/ast_drv.c| 1 - drivers/gpu/drm/cirrus/cirrus_drv.c | 1 - drivers/gpu/drm/drm_fops.c | 14 -- drivers/gpu/drm/gma500/psb_drv.c | 1 - drivers/gpu/drm/i810/i810_dma.c | 1 - drivers/gpu/drm/i810/i810_drv.c | 1 - drivers/gpu/drm/i915/i915_drv.c | 1 - drivers/gpu/drm/mga/mga_drv.c| 1 - drivers/gpu/drm/mgag200/mgag200_drv.c| 1 - drivers/gpu/drm/nouveau/nouveau_drm.c| 1 - drivers/gpu/drm/omapdrm/omap_drv.c | 1 - drivers/gpu/drm/qxl/qxl_drv.c| 1 - drivers/gpu/drm/r128/r128_drv.c | 1 - drivers/gpu/drm/radeon/radeon_drv.c | 2 -- drivers/gpu/drm/rcar-du/rcar_du_drv.c| 1 - drivers/gpu/drm/savage/savage_drv.c | 1 - drivers/gpu/drm/shmobile/shmob_drm_drv.c | 1 - drivers/gpu/drm/sis/sis_drv.c| 1 - drivers/gpu/drm/tdfx/tdfx_drv.c | 1 - drivers/gpu/drm/tilcdc/tilcdc_drv.c | 1 - drivers/gpu/drm/udl/udl_drv.c| 1 - drivers/gpu/drm/via/via_drv.c| 1 - drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 1 - drivers/gpu/host1x/drm/drm.c | 1 - drivers/staging/imx-drm/imx-drm-core.c | 1 - include/drm/drmP.h | 3 --- 27 files changed, 43 deletions(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 4d54ac8..79dd70e 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2498,7 +2498,6 @@ void (*postclose) (struct drm_device *, struct drm_file *);/synopsis programlisting .poll = drm_poll, .read = drm_read, - .fasync = drm_fasync, .llseek = no_llseek, /programlisting /para diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c index df0d0a0..16050ed 100644 --- a/drivers/gpu/drm/ast/ast_drv.c +++ b/drivers/gpu/drm/ast/ast_drv.c @@ -190,7 +190,6 @@ static const struct file_operations ast_fops = { .unlocked_ioctl = drm_ioctl, .mmap = ast_mmap, .poll = drm_poll, - .fasync = drm_fasync, #ifdef CONFIG_COMPAT .compat_ioctl = drm_compat_ioctl, #endif diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c index 8ecb601..85748f6 100644 --- a/drivers/gpu/drm/cirrus/cirrus_drv.c +++ b/drivers/gpu/drm/cirrus/cirrus_drv.c @@ -85,7 +85,6 @@ static const struct file_operations cirrus_driver_fops = { #ifdef CONFIG_COMPAT .compat_ioctl = drm_compat_ioctl, #endif - .fasync = drm_fasync, }; static struct drm_driver driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_USE_MTRR, diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm
Re: [PATCH] drm: don't call -firstopen for KMS drivers
Hi Daniel, On Wednesday 10 July 2013 20:17:44 Daniel Vetter wrote: It has way too much potential for driver writers to do stupid things like delayed hw setup because the load sequence is somehow racy (e.g. the imx driver in staging). So don't call it for modesetting drivers, which reduces the complexity of the drm core - driver interface a notch. v2: Don't forget to update DocBook. Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch --- Documentation/DocBook/drm.tmpl | 2 ++ drivers/gpu/drm/drm_fops.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 4d54ac8..0e8a5a3 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2423,6 +2423,8 @@ void (*postclose) (struct drm_device *, struct drm_file *);/synopsis para The methodnamefirstopen/methodname method is called by the DRM core when an application opens a device that has no other opened file handle. + Not that this callback is only called for legacy ums drm drivers, not + for drm drivers that implement modesetting in the kernel. Similarly the methodnamelastclose/methodname method is called when the last application holding a file handle opened on the device closes it. Both methods are mostly used for UMS (User Mode Setting) drivers to What about diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 7d1278e..afa8d40 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2422,18 +2422,18 @@ void (*postclose) (struct drm_device *, struct drm_file *);/synopsis /abstract para The methodnamefirstopen/methodname method is called by the DRM core - when an application opens a device that has no other opened file handle. - Similarly the methodnamelastclose/methodname method is called when - the last application holding a file handle opened on the device closes - it. Both methods are mostly used for UMS (User Mode Setting) drivers to - acquire and release device resources which should be done in the - methodnameload/methodname and methodnameunload/methodname - methods for KMS drivers. + for legacy UMS (User Mode Setting) drivers only when an application + opens a device that has no other opened file handle. UMS drivers can + implement it to acquire device resources. KMS drivers can't use the + method and must acquire resources in the methodnameload/methodname + method instead. /para para -Note that the methodnamelastclose/methodname method is also called - at module unload time or, for hot-pluggable devices, when the device is - unplugged. The methodnamefirstopen/methodname and + Similarly the methodnamelastclose/methodname method is called when + the last application holding a file handle opened on the device closes + it, for both UMS and KMS drivers. Additionally, the method is also + called at module unload time or, for hot-pluggable devices, when the + device is unplugged. The methodnamefirstopen/methodname and methodnamelastclose/methodname calls can thus be unbalanced. /para para diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index 57e3014..fcde7d4 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -51,7 +51,8 @@ static int drm_setup(struct drm_device * dev) int i; int ret; - if (dev-driver-firstopen) { + if (dev-driver-firstopen + !drm_core_check_feature(dev, DRIVER_MODESET)) { ret = dev-driver-firstopen(dev); if (ret != 0) return ret; -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm/prime: remove cargo-cult locking from map_sg helper
Hi Daniel, Thanks for the patch. On Wednesday 10 July 2013 16:48:45 Daniel Vetter wrote: I've checked both implementations (radeon/nouveau) and they both grab the page array from ttm simply by dereferencing it and then wrapping it up with drm_prime_pages_to_sg in the callback and map it with dma_map_sg (in the helper). Only the grabbing of the underlying page array is anything we need to be concerned about, and either those pages are pinned independently, or we're screwed no matter what. And indeed, nouveau/radeon pin the backing storage in their attach/detach functions. Since I've created this patch cma prime support for dma_buf was added. drm_gem_cma_prime_get_sg_table only calls kzalloc and the createsmaps the sg table with dma_get_sgtable. It doesn't touch any gem object state otherwise. So the cma helpers also look safe. The only thing we might claim it does is prevent concurrent mapping of dma_buf attachments. But a) that's not allowed and b) the current code is racy already since it checks whether the sg mapping exists _before_ grabbing the lock. So the dev-struct_mutex locking here does absolutely nothing useful, but only distracts. Remove it. This should also help Maarten's work to eventually pin the backing storage more dynamically by preventing locking inversions around dev-struct_mutex. v2: Add analysis for recently added cma helper prime code. Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com Cc: Maarten Lankhorst maarten.lankho...@canonical.com Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- drivers/gpu/drm/drm_prime.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 85e450e..64a99b3 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -167,8 +167,6 @@ static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, if (WARN_ON(prime_attach-dir != DMA_NONE)) return ERR_PTR(-EBUSY); - mutex_lock(obj-dev-struct_mutex); - sgt = obj-dev-driver-gem_prime_get_sg_table(obj); if (!IS_ERR(sgt)) { @@ -182,7 +180,6 @@ static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, } } - mutex_unlock(obj-dev-struct_mutex); return sgt; } -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 0/2][RFC] CDFv2 for VExpress HDLCD DVI output support
On Wednesday 17 July 2013 11:49:49 Pawel Moll wrote: On Wed, 2013-07-17 at 11:08 +0100, Show Liu wrote: This series patches extend Pawel's patches to Versatile Express HDLCD DVI output support. Before apply this patches, please apply Pawel's patches first. This series patches implements base on Linaro release 13.06 branch ll_20130621.0. here is Pawel's patches [1] http://lists.freedesktop.org/archives/dri-devel/2013-April/037519.html Glad to see someone thinking the same way ;-) Thanks for trying it and particularly for the fixes in vexpress-* code. I'll keep them in mind when the time comes :-) Of course neither the CDF patch nor the HDLCD driver are upstream yet. Laurent promised to post next (hopefully final ;-) I don't think it will be the final version, but there should be no major change to the API after that. I still expect a couple of versions before the code reaches a mergeable stable, but it shouldn't take too long this time. Further enhancements then will likely go in as follow-up patchs. version of his patches soon, Hopefully by the end of the week (which ends on Sunday, not Friday ;-)), give or take a couple of days. but the API has apparently changed so we'll have to adapt to it. As to the HDLCD driver - there is some work going on converting it to DRM/KMS and upstreaming as such, using CDF if it's available by that time as well. -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[GIT PULL FOR v3.11] SH Mobile DRM and R-Car DU DRM fixes
Hi Dave, The SH Mobile DRM and R-Car DU DRM drivers fail to compile on v3.11-rc1 due to usage of an API that has been removed. Could you please pull these fixes for v3.11 ? The sooner would be the better, to avoid as many bisection issues as possible. The following changes since commit ad81f0545ef01ea651886dddac4bef6cec930092: Linux 3.11-rc1 (2013-07-14 15:18:27 -0700) are available in the git repository at: git://linuxtv.org/pinchartl/fbdev.git drm/3.11/fixes for you to fetch changes up to ffb40400762d86a34318160e8f2169b66f01473d: drm/rcar-du: Use the GEM PRIME helpers (2013-07-17 15:44:01 +0200) Laurent Pinchart (2): drm/shmobile: Use the GEM PRIME helpers drm/rcar-du: Use the GEM PRIME helpers drivers/gpu/drm/rcar-du/rcar_du_drv.c| 9 +++-- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 9 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
CFP for Graphics and Display uConf at LPC 2013
Hi all, It's time to start nailing down the agenda for the Graphics and Display microconference at the Linux Plumbers Conference 2013. For conference approval and preliminary planning purposes, we have compiled a list of possible topics for discussion. The overview and general list of topic ideas is available here: http://wiki.linuxplumbersconf.org/2013:graphics_and_display The final topics for the microconference need to be formally proposed and accepted. We would like to focus on topics which would benefit from discussion to determine project/feature direction, rather than those which are well defined and looking for a likely person to do an implementation. Instructions for how to formally submit a presentation are available here: http://www.linuxplumbersconf.org/2013/submitting-microconference-discussion-topics/ Please feel free to update the wiki if there are topic ideas you think we have overlooked, and feel free to start a thread in response to this message if you want a more public forum for validating your topic idea; of course, you should also be submitting your ideas formally :-). We are also thinking that there may be some topics that could cross over with the Android microconference (leads on cc). For key attendees who think they will need travel assistance to attend, the deadline is July 18th, the budget is very limited, and the requests need to go through the conference committee. If you have any questions or concerns about the microconference, please feel free to contact us. Looking forward to seeing everyone in New Orleans. -- Thanks in advance, Jesse Barker (jesse 'dot' barker 'at' arm 'dot' com) Laurent Pinchart (laurent 'dot' pinchart 'at' ideasonboard 'dot' com) ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH] drm: don't call -firstopen for KMS drivers
Hi Daniel, Thank you for the patch. On Saturday 13 July 2013 16:45:10 Daniel Vetter wrote: It has way too much potential for driver writers to do stupid things like delayed hw setup because the load sequence is somehow racy (e.g. the imx driver in staging). So don't call it for modesetting drivers, which reduces the complexity of the drm core - driver interface a notch. v2: Don't forget to update DocBook. v3: Go with Laurent's slightly more elaborate proposal for the DocBook update. Add a few words on top of his diff to elaborate a bit on what KMS drivers should and shouldn't do in lastclose. There was already a paragraph present talking about restoring properties, I've simply extended that one. Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- Documentation/DocBook/drm.tmpl | 27 --- drivers/gpu/drm/drm_fops.c | 3 ++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 4d54ac8..52d5eda 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl @@ -2422,18 +2422,18 @@ void (*postclose) (struct drm_device *, struct drm_file *);/synopsis /abstract para The methodnamefirstopen/methodname method is called by the DRM core -when an application opens a device that has no other opened file handle. - Similarly the methodnamelastclose/methodname method is called when -the last application holding a file handle opened on the device closes - it. Both methods are mostly used for UMS (User Mode Setting) drivers to - acquire and release device resources which should be done in the - methodnameload/methodname and methodnameunload/methodname - methods for KMS drivers. + for legacy UMS (User Mode Setting) drivers only when an application + opens a device that has no other opened file handle. UMS drivers can + implement it to acquire device resources. KMS drivers can't use the + method and must acquire resources in the methodnameload/methodname + method instead. /para para -Note that the methodnamelastclose/methodname method is also called - at module unload time or, for hot-pluggable devices, when the device is - unplugged. The methodnamefirstopen/methodname and + Similarly the methodnamelastclose/methodname method is called when + the last application holding a file handle opened on the device closes + it, for both UMS and KMS drivers. Additionally, the method is also + called at module unload time or, for hot-pluggable devices, when the + device is unplugged. The methodnamefirstopen/methodname and methodnamelastclose/methodname calls can thus be unbalanced. /para para @@ -2462,7 +2462,12 @@ void (*postclose) (struct drm_device *, struct drm_file *);/synopsis para The methodnamelastclose/methodname method should restore CRTC and plane properties to default value, so that a subsequent open of the - device will not inherit state from the previous user. + device will not inherit state from the previous user. It can also be + used to execute delayed power switching state changes, e.g. in + conjunction with the vga-switcheroo infrastructure. Beyond that KMS + drivers should not do any further cleanup. Only legacy UMS drivers might + need to clean up device state so that the vga console or an independent + fbdev driver could take over. /para /sect2 sect2 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index 57e3014..fcde7d4 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -51,7 +51,8 @@ static int drm_setup(struct drm_device * dev) int i; int ret; - if (dev-driver-firstopen) { + if (dev-driver-firstopen + !drm_core_check_feature(dev, DRIVER_MODESET)) { ret = dev-driver-firstopen(dev); if (ret != 0) return ret; -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 13/20] drm/gem: create drm_gem_dumb_destroy
Hi Daniel, Thanks for the patch. On Tuesday 16 July 2013 09:12:04 Daniel Vetter wrote: All the gem based kms drivers really want the same function to destroy a dumb framebuffer backing storage object. So give it to them and roll it out in all drivers. This still leaves the option open for kms drivers which don't use GEM for backing storage, but it does decently simplify matters for gem drivers. Cc: Inki Dae inki@samsung.com Cc: Laurent Pinchart laurent.pinch...@ideasonboard.com Cc: Intel Graphics Development intel-...@lists.freedesktop.org Cc: Ben Skeggs skeg...@gmail.com Cc: Rob Clark robdcl...@gmail.com Cc: Alex Deucher alexdeuc...@gmail.com Signed-off-by: Daniel Vetter daniel.vet...@ffwll.ch Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- drivers/gpu/drm/ast/ast_drv.c | 2 +- drivers/gpu/drm/ast/ast_drv.h | 3 --- drivers/gpu/drm/ast/ast_main.c| 7 --- drivers/gpu/drm/cirrus/cirrus_drv.c | 2 +- drivers/gpu/drm/cirrus/cirrus_drv.h | 3 --- drivers/gpu/drm/cirrus/cirrus_main.c | 7 --- drivers/gpu/drm/drm_gem.c | 14 ++ drivers/gpu/drm/drm_gem_cma_helper.c | 10 -- drivers/gpu/drm/exynos/exynos_drm_drv.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_gem.c | 20 drivers/gpu/drm/exynos/exynos_drm_gem.h | 9 - drivers/gpu/drm/gma500/gem.c | 17 - drivers/gpu/drm/gma500/psb_drv.c | 2 +- drivers/gpu/drm/gma500/psb_drv.h | 2 -- drivers/gpu/drm/i915/i915_drv.c | 2 +- drivers/gpu/drm/i915/i915_drv.h | 2 -- drivers/gpu/drm/i915/i915_gem.c | 7 --- drivers/gpu/drm/mgag200/mgag200_drv.c | 2 +- drivers/gpu/drm/mgag200/mgag200_drv.h | 3 --- drivers/gpu/drm/mgag200/mgag200_main.c| 7 --- drivers/gpu/drm/nouveau/nouveau_display.c | 7 --- drivers/gpu/drm/nouveau/nouveau_display.h | 2 -- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- drivers/gpu/drm/omapdrm/omap_drv.c| 2 +- drivers/gpu/drm/omapdrm/omap_drv.h| 2 -- drivers/gpu/drm/omapdrm/omap_gem.c| 15 --- drivers/gpu/drm/qxl/qxl_drv.c | 2 +- drivers/gpu/drm/qxl/qxl_drv.h | 3 --- drivers/gpu/drm/qxl/qxl_dumb.c| 7 --- drivers/gpu/drm/radeon/radeon.h | 3 --- drivers/gpu/drm/radeon/radeon_drv.c | 5 + drivers/gpu/drm/radeon/radeon_gem.c | 7 --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 +- drivers/gpu/drm/shmobile/shmob_drm_drv.c | 2 +- drivers/gpu/drm/tilcdc/tilcdc_drv.c | 2 +- drivers/gpu/drm/udl/udl_drv.c | 2 +- drivers/gpu/drm/udl/udl_drv.h | 2 -- drivers/gpu/drm/udl/udl_gem.c | 6 -- drivers/gpu/host1x/drm/drm.c | 2 +- drivers/gpu/host1x/drm/gem.c | 6 -- drivers/gpu/host1x/drm/gem.h | 2 -- drivers/staging/imx-drm/imx-drm-core.c| 2 +- include/drm/drmP.h| 3 +++ include/drm/drm_gem_cma_helper.h | 8 44 files changed, 33 insertions(+), 186 deletions(-) -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 01/23] drm/rcar-du: Add missing alpha plane register definitions
Several alpha plane register definitions are missing, add them. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_regs.h | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_regs.h b/drivers/gpu/drm/rcar-du/rcar_du_regs.h index 69f21f1..3aba27f 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_regs.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_regs.h @@ -349,10 +349,25 @@ #define APnMR_BM_AD(2 4)/* Auto Display Change Mode */ #define APnMWR 0x0a104 + +#define APnDSXR0x0a110 +#define APnDSYR0x0a114 +#define APnDPXR0x0a118 +#define APnDPYR0x0a11c + #define APnDSA0R 0x0a120 #define APnDSA1R 0x0a124 #define APnDSA2R 0x0a128 + +#define APnSPXR0x0a130 +#define APnSPYR0x0a134 +#define APnWASPR 0x0a138 +#define APnWAMWR 0x0a13c + +#define APnBTR 0x0a140 + #define APnMLR 0x0a150 +#define APnSWAPR 0x0a180 /* - * Display Capture Registers -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 00/23] R-Car DU DRM support for R8A7790
Hello, Here's the second version of a patch set that adds support for the DU found in the R8A7790 SoC. Compared to the R8A7779 DU, the R8A7790 has a third CRTC, internal LVDS encoders and different output routing options. These patches are based on the drm-next branch are are targetted at v3.12. Laurent Pinchart (23): drm/rcar-du: Add missing alpha plane register definitions drm/rcar-du: Use devm_ioremap_resource() drm/rcar-du: Add platform module device table drm/rcar-du: Support per-CRTC clock and IRQ drm/rcar-du: Clarify comment regarding plane Y source coordinate drm/rcar-du: Split LVDS encoder and connector drm/rcar-du: Split VGA encoder and connector drm/rcar-du: Merge LVDS and VGA encoder code drm/rcar-du: Rename platform data fields to match what they describe drm/rcar-du: Create rcar_du_planes structure drm/rcar-du: Rename rcar_du_plane_(init|register) to rcar_du_planes_* drm/rcar-du: Introduce CRTCs groups drm/rcar-du: Use dynamic number of CRTCs instead of CRTCs array size drm/rcar-du: Remove register definitions for the second channel drm/rcar-du: Move output routing configuration to group drm/rcar-du: Add support for the R8A7790 DU drm/rcar-du: Fix buffer pitch alignment for R8A7790 DU drm/rcar-du: Add support for multiple groups drm/rcar-du: Add support for DEFR8 register drm/rcar-du: Rework output routing support drm/rcar-du: Configure RGB output routing to DPAD0 drm/rcar-du: Add internal LVDS encoder support drm/rcar-du: Add FBDEV emulation support drivers/gpu/drm/rcar-du/Kconfig | 7 + drivers/gpu/drm/rcar-du/Makefile | 10 +- drivers/gpu/drm/rcar-du/rcar_du_crtc.c| 255 -- drivers/gpu/drm/rcar-du/rcar_du_crtc.h| 13 +- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 173 +--- drivers/gpu/drm/rcar-du/rcar_du_drv.h | 63 ++-- drivers/gpu/drm/rcar-du/rcar_du_encoder.c | 202 +++ drivers/gpu/drm/rcar-du/rcar_du_encoder.h | 49 ++ drivers/gpu/drm/rcar-du/rcar_du_group.c | 187 ++ drivers/gpu/drm/rcar-du/rcar_du_group.h | 50 ++ drivers/gpu/drm/rcar-du/rcar_du_kms.c | 165 +++ drivers/gpu/drm/rcar-du/rcar_du_kms.h | 29 +--- drivers/gpu/drm/rcar-du/rcar_du_lvds.c| 216 - drivers/gpu/drm/rcar-du/rcar_du_lvds.h| 24 --- drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c | 131 +++ drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h | 25 +++ drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c | 196 +++ drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h | 46 ++ drivers/gpu/drm/rcar-du/rcar_du_plane.c | 170 ++-- drivers/gpu/drm/rcar-du/rcar_du_plane.h | 26 ++- drivers/gpu/drm/rcar-du/rcar_du_regs.h| 94 +-- drivers/gpu/drm/rcar-du/rcar_du_vga.c | 149 - drivers/gpu/drm/rcar-du/rcar_du_vga.h | 24 --- drivers/gpu/drm/rcar-du/rcar_du_vgacon.c | 96 +++ drivers/gpu/drm/rcar-du/rcar_du_vgacon.h | 23 +++ drivers/gpu/drm/rcar-du/rcar_lvds_regs.h | 69 include/linux/platform_data/rcar-du.h | 34 +++- 27 files changed, 1665 insertions(+), 861 deletions(-) create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_encoder.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_encoder.h create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_group.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_group.h delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvds.c delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvds.h create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vga.c delete mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vga.h create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vgacon.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_vgacon.h create mode 100644 drivers/gpu/drm/rcar-du/rcar_lvds_regs.h -- Regards, Laurent Pinchart ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 02/23] drm/rcar-du: Use devm_ioremap_resource()
Replace the devm_request_mem_region() and devm_ioremap_nocache() calls with devm_ioremap_resource(). Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 22 +++--- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index dc0fe09..f776b1c 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -107,7 +107,6 @@ static int rcar_du_load(struct drm_device *dev, unsigned long flags) struct platform_device *pdev = dev-platformdev; struct rcar_du_platform_data *pdata = pdev-dev.platform_data; struct rcar_du_device *rcdu; - struct resource *ioarea; struct resource *mem; int ret; @@ -129,24 +128,9 @@ static int rcar_du_load(struct drm_device *dev, unsigned long flags) /* I/O resources and clocks */ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (mem == NULL) { - dev_err(pdev-dev, failed to get memory resource\n); - return -EINVAL; - } - - ioarea = devm_request_mem_region(pdev-dev, mem-start, -resource_size(mem), pdev-name); - if (ioarea == NULL) { - dev_err(pdev-dev, failed to request memory region\n); - return -EBUSY; - } - - rcdu-mmio = devm_ioremap_nocache(pdev-dev, ioarea-start, - resource_size(ioarea)); - if (rcdu-mmio == NULL) { - dev_err(pdev-dev, failed to remap memory resource\n); - return -ENOMEM; - } + rcdu-mmio = devm_ioremap_resource(pdev-dev, mem); + if (IS_ERR(rcdu-mmio)) + return PTR_ERR(rcdu-mmio); rcdu-clock = devm_clk_get(pdev-dev, NULL); if (IS_ERR(rcdu-clock)) { -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 03/23] drm/rcar-du: Add platform module device table
The platform device id driver data field points to a device information structure that only contains a (currently empty) features field for now. Support for additional model-dependent features will be added later. Only the R8A7779 variant is currently supported. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_drv.c | 13 + drivers/gpu/drm/rcar-du/rcar_du_drv.h | 15 +++ 2 files changed, 28 insertions(+) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index f776b1c..bb7193d 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c @@ -123,6 +123,7 @@ static int rcar_du_load(struct drm_device *dev, unsigned long flags) rcdu-dev = pdev-dev; rcdu-pdata = pdata; + rcdu-info = (struct rcar_du_device_info *)pdev-id_entry-driver_data; rcdu-ddev = dev; dev-dev_private = rcdu; @@ -297,6 +298,17 @@ static int rcar_du_remove(struct platform_device *pdev) return 0; } +static const struct rcar_du_device_info rcar_du_r8a7779_info = { + .features = 0, +}; + +static const struct platform_device_id rcar_du_id_table[] = { + { rcar-du-r8a7779, (kernel_ulong_t)rcar_du_r8a7779_info }, + { } +}; + +MODULE_DEVICE_TABLE(platform, rcar_du_id_table); + static struct platform_driver rcar_du_platform_driver = { .probe = rcar_du_probe, .remove = rcar_du_remove, @@ -305,6 +317,7 @@ static struct platform_driver rcar_du_platform_driver = { .name = rcar-du, .pm = rcar_du_pm_ops, }, + .id_table = rcar_du_id_table, }; module_platform_driver(rcar_du_platform_driver); diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.h b/drivers/gpu/drm/rcar-du/rcar_du_drv.h index 193cc59..06dbf4f 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.h @@ -25,9 +25,18 @@ struct clk; struct device; struct drm_device; +/* + * struct rcar_du_device_info - DU model-specific information + * @features: device features (RCAR_DU_FEATURE_*) + */ +struct rcar_du_device_info { + unsigned int features; +}; + struct rcar_du_device { struct device *dev; const struct rcar_du_platform_data *pdata; + const struct rcar_du_device_info *info; void __iomem *mmio; struct clk *clock; @@ -50,6 +59,12 @@ struct rcar_du_device { } planes; }; +static inline bool rcar_du_has(struct rcar_du_device *rcdu, + unsigned int feature) +{ + return rcdu-info-features feature; +} + int rcar_du_get(struct rcar_du_device *rcdu); void rcar_du_put(struct rcar_du_device *rcdu); -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 05/23] drm/rcar-du: Clarify comment regarding plane Y source coordinate
The R8A7790 DU documentation contains further information regarding the plane Y source coordinate. Update the comment accordingly. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/rcar_du_plane.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_plane.c b/drivers/gpu/drm/rcar-du/rcar_du_plane.c index a65f81d..38ebd20 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_plane.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_plane.c @@ -103,9 +103,12 @@ void rcar_du_plane_update_base(struct rcar_du_plane *plane) struct rcar_du_device *rcdu = plane-dev; unsigned int index = plane-hwindex; - /* According to the datasheet the Y position is expressed in raster line -* units. However, 32bpp formats seem to require a doubled Y position -* value. Similarly, for the second plane, NV12 and NV21 formats seem to + /* The Y position is expressed in raster line units and must be doubled +* for 32bpp formats, according to the R8A7790 datasheet. No mention of +* doubling the Y position is found in the R8A7779 datasheet, but the +* rule seems to apply there as well. +* +* Similarly, for the second plane, NV12 and NV21 formats seem to * require a halved Y position value. */ rcar_du_plane_write(rcdu, index, PnSPXR, plane-src_x); -- 1.8.1.5 ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 06/23] drm/rcar-du: Split LVDS encoder and connector
This prepares for the encoders rework. Signed-off-by: Laurent Pinchart laurent.pinchart+rene...@ideasonboard.com --- drivers/gpu/drm/rcar-du/Makefile | 1 + drivers/gpu/drm/rcar-du/rcar_du_lvds.c| 120 +-- drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c | 130 ++ drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h | 25 ++ 4 files changed, 158 insertions(+), 118 deletions(-) create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile index 7333c00..5def510 100644 --- a/drivers/gpu/drm/rcar-du/Makefile +++ b/drivers/gpu/drm/rcar-du/Makefile @@ -2,6 +2,7 @@ rcar-du-drm-y := rcar_du_crtc.o \ rcar_du_drv.o \ rcar_du_kms.o \ rcar_du_lvds.o \ +rcar_du_lvdscon.o \ rcar_du_plane.o \ rcar_du_vga.o diff --git a/drivers/gpu/drm/rcar-du/rcar_du_lvds.c b/drivers/gpu/drm/rcar-du/rcar_du_lvds.c index 7aefe72..82e5157 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_lvds.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_lvds.c @@ -1,5 +1,5 @@ /* - * rcar_du_lvds.c -- R-Car Display Unit LVDS Encoder and Connector + * rcar_du_lvds.c -- R-Car Display Unit LVDS Encoder * * Copyright (C) 2013 Renesas Corporation * @@ -18,123 +18,7 @@ #include rcar_du_drv.h #include rcar_du_kms.h #include rcar_du_lvds.h - -struct rcar_du_lvds_connector { - struct rcar_du_connector connector; - - const struct rcar_du_panel_data *panel; -}; - -#define to_rcar_lvds_connector(c) \ - container_of(c, struct rcar_du_lvds_connector, connector.connector) - -/* - - * Connector - */ - -static int rcar_du_lvds_connector_get_modes(struct drm_connector *connector) -{ - struct rcar_du_lvds_connector *lvdscon = to_rcar_lvds_connector(connector); - struct drm_display_mode *mode; - - mode = drm_mode_create(connector-dev); - if (mode == NULL) - return 0; - - mode-type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; - mode-clock = lvdscon-panel-mode.clock; - mode-hdisplay = lvdscon-panel-mode.hdisplay; - mode-hsync_start = lvdscon-panel-mode.hsync_start; - mode-hsync_end = lvdscon-panel-mode.hsync_end; - mode-htotal = lvdscon-panel-mode.htotal; - mode-vdisplay = lvdscon-panel-mode.vdisplay; - mode-vsync_start = lvdscon-panel-mode.vsync_start; - mode-vsync_end = lvdscon-panel-mode.vsync_end; - mode-vtotal = lvdscon-panel-mode.vtotal; - mode-flags = lvdscon-panel-mode.flags; - - drm_mode_set_name(mode); - drm_mode_probed_add(connector, mode); - - return 1; -} - -static int rcar_du_lvds_connector_mode_valid(struct drm_connector *connector, - struct drm_display_mode *mode) -{ - return MODE_OK; -} - -static const struct drm_connector_helper_funcs connector_helper_funcs = { - .get_modes = rcar_du_lvds_connector_get_modes, - .mode_valid = rcar_du_lvds_connector_mode_valid, - .best_encoder = rcar_du_connector_best_encoder, -}; - -static void rcar_du_lvds_connector_destroy(struct drm_connector *connector) -{ - drm_sysfs_connector_remove(connector); - drm_connector_cleanup(connector); -} - -static enum drm_connector_status -rcar_du_lvds_connector_detect(struct drm_connector *connector, bool force) -{ - return connector_status_connected; -} - -static const struct drm_connector_funcs connector_funcs = { - .dpms = drm_helper_connector_dpms, - .detect = rcar_du_lvds_connector_detect, - .fill_modes = drm_helper_probe_single_connector_modes, - .destroy = rcar_du_lvds_connector_destroy, -}; - -static int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu, - struct rcar_du_encoder *renc, - const struct rcar_du_panel_data *panel) -{ - struct rcar_du_lvds_connector *lvdscon; - struct drm_connector *connector; - int ret; - - lvdscon = devm_kzalloc(rcdu-dev, sizeof(*lvdscon), GFP_KERNEL); - if (lvdscon == NULL) - return -ENOMEM; - - lvdscon-panel = panel; - - connector = lvdscon-connector.connector; - connector-display_info.width_mm = panel-width_mm; - connector-display_info.height_mm = panel-height_mm; - - ret = drm_connector_init(rcdu-ddev, connector, connector_funcs, -DRM_MODE_CONNECTOR_LVDS); - if (ret 0) - return ret; - - drm_connector_helper_add(connector, connector_helper_funcs); - ret = drm_sysfs_connector_add(connector); - if (ret 0) - return ret; - - drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF