[Bug 54675] [RADEON:KMS:RV730XT:HDMI:AUDIO] Screaming audio IRQ with 3.5.3 kernel

2012-09-09 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=54675

--- Comment #3 from Chris Rankin  2012-09-09 
00:17:26 UTC ---
According to alsamixer, my HD4670 only has a S/PDIF playback device. However,
my HD4890 has both S/PDIF and PCM playback devices. I don't know whether this
is significant.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


[Bug 42490] NUTMEG DP to VGA bridge not working

2012-09-09 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=42490

--- Comment #42 from diego.abelenda at gmail.com 2012-09-09 07:33:54 UTC ---
I take back what I said before...
I just did a *very* cold boot (the machine was not connected to the electricity
network during the night). I got the black DVI screen and GPU hangup with the
patch. So the firmware change didn't do anything in facts...

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


glapi/libdricore linking trouble with make install targets

2012-09-09 Thread Andreas Radke
When building packages in ArchLinux we try to avoid the old
bin/minstall to move each and every file by hand. So we try to move to
make install targets. Here we run into several linking issues:

  make -C src/glx DESTDIR="${pkgdir}" install

fails with:

make[2]: Entering directory 
`/build/src/mesa-41d14eaf193c6b1eb87fe1998808a887f1c6c698/src/glx'
make[2]: Nothing to be done for `install-data-am'.
 /usr/bin/mkdir -p '/build/pkg/libgl/usr/lib'
 /bin/sh ../../libtool   --mode=install /usr/bin/install -c   libGL.la 
'/build/pkg/libgl/usr/lib'
libtool: install: warning: relinking `libGL.la'
libtool: install: (cd 
/build/src/mesa-41d14eaf193c6b1eb87fe1998808a887f1c6c698/src/glx; /bin/sh 
/build/src/mesa-41d14eaf193c6b1eb87fe1998808a887f1c6c698/libtool  --silent 
--tag CC --mode=relink gcc -I../../include -I../../include/GL/internal 
-I../../src/mapi -I../../src/mapi/glapi -I../../src/mapi -I../../src/mapi/glapi 
-DGLX_SHARED_GLAPI -DXF86VIDMODE -D_REENTRANT 
-DDEFAULT_DRIVER_DIR=\"/usr/lib/xorg/modules/dri\" -D_GNU_SOURCE -DPTHREADS 
-DTEXTURE_FLOAT_ENABLED -DUSE_X86_64_ASM -DHAVE_DLOPEN -DHAVE_POSIX_MEMALIGN 
-DIN_DRI_DRIVER -DUSE_XCB -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING 
-DGLX_USE_TLS -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER -DHAVE_ALIAS 
-DHAVE_MINCORE -DHAVE_LIBUDEV -DHAVE_LLVM=0x0301 -I/usr/include/libdrm 
-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector 
--param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -Wall -std=c99 
-Werror=implicit-function-declaration -Werror=missing-prototypes 
-fno-strict-aliasing -fno-builtin-memcmp -Wl,-Bsymbolic -vers
 ion-number 1:2 -no-undefined -Wl,-O1,--sort-common,--as-needed,-z,relro -o 
libGL.la -rpath /usr/lib libglx.la ../../src/mapi/shared-glapi/libglapi.la 
../../src/mapi/glapi/libglapi.la -lXext -lXdamage -lXfixes -lX11-xcb -lX11 
-lxcb-glx -lxcb -lXxf86vm -ldrm -lm -lpthread -ldl -inst-prefix-dir 
/build/pkg/libgl)
/usr/bin/ld: cannot find -lglapi
collect2: error: ld returned 1 exit status
libtool: install: error: relink `libGL.la' with the above command before 
installing it
make[2]: *** [install-libLTLIBRARIES] Error 1


Similar errors happen with other targets. Our community found
a workaround by running this:

  # fix linking because of splitted package
  make -C src/mapi/shared-glapi DESTDIR="${pkgdir}" install

  # libGL & libdricore
  make -C src/glx DESTDIR="${pkgdir}" install
  make -C src/mesa/libdricore DESTDIR="${pkgdir}" install

  # fix linking because of splitted package - cleanup
  make -C src/mapi/shared-glapi DESTDIR="${pkgdir}" uninstall



Such step seems to be needed for these other target directories:

* make -C src/egl DESTDIR="${pkgdir}" install
* make -C src/gbm DESTDIR="${pkgdir}" install

Similar issues seem to be there when trying to install the driver targets 
(intel, ati and nouveau),
the workaround seems to be then:

  # fix linking because of splitted package
  make -C src/mesa/libdricore DESTDIR="${pkgdir}" install

  make -C src/mesa/drivers/dri/i915 DESTDIR="${pkgdir}" install
  make -C src/mesa/drivers/dri/i965 DESTDIR="${pkgdir}" install

  # fix linking because of splitted package - cleanup
  make -C src/mesa/libdricore DESTDIR="${pkgdir}" uninstall


Can't these targets do proper linking on their own?

-Andy
ArchLinux


[Bug 43360] nouveau on "NVce" 560 Ti: Failed to idle channel 1

2012-09-09 Thread bugzilla-dae...@bugzilla.kernel.org
https://bugzilla.kernel.org/show_bug.cgi?id=43360





--- Comment #5 from s.jegen at gmail.com  2012-09-09 08:08:37 ---
Using Linus' git tree
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git (v3.6-rc4) at

commit eeea3ac912207dcf759b95b2b4c36f96bce583bf
Merge: c7c6bf1 e829c66
Author: Linus Torvalds <*>
Date:   Thu Sep 6 10:23:58 2012 -0700

everything seems to work just fine on my "NVIDIA Corporation GF110 [GeForce GTX
570 HD]". 'dmesg' does not seem to show any warnings or errors and the VT
framebuffer is displayed in a beautifully high resolution. Great work!

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.


[Bug 54129] [bisected] Kernel 3.5.0 breaks KMS on Radeon RV250

2012-09-09 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=54129

Christian K?nig  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 AssignedTo|dri-devel at lists.freedesktop |deathsimple at vodafone.de
   |.org|

--- Comment #11 from Christian K?nig  2012-09-09 
09:47:55 UTC ---
Created attachment 66876
  --> https://bugs.freedesktop.org/attachment.cgi?id=66876
Possible fix

Please try the attached patch.

Also please supply the output of "sudo cat
/sys/kernel/debug/dri/0/radeon_fence_info" with and without this patch.

Thx,
Christian.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


[Bug 54675] [RADEON:KMS:RV730XT:HDMI:AUDIO] Screaming audio IRQ with 3.5.3 kernel

2012-09-09 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=54675

--- Comment #4 from Chris Rankin  2012-09-09 
11:21:38 UTC ---
Apparently, the KMS IRQ can fail even when radeon.audio=0. So it looks like the
audio IRQ always fails and sometimes takes the KMS IRQ with it - seemingly at
random.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


[Bug 54675] [RADEON:KMS:RV730XT:HDMI:AUDIO] Screaming audio IRQ with 3.5.3 kernel

2012-09-09 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=54675

--- Comment #5 from Chris Rankin  2012-09-09 
13:38:27 UTC ---
"lspci -n" output for the HD4670:

01:00.0 0300: 1002:9495
01:00.1 0403: 1002:aa38

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


[Bug 54662] [bisected] Kernel 3.6 breaks KMS on Radeon RV530 (black screen)

2012-09-09 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=54662

--- Comment #4 from Simon Kitching  2012-09-09 
13:43:26 UTC ---
(In reply to comment #1)
> Can you attach the dmesg output from the non-working case?

Hi Alex,

Thanks very much for your suggestions. 

I'm not sure how to obtain dmesg output, given that I can't get a console in
the failing case. The normal login screen is black, ctrl-alt-f2 doesn't work.
Unfortunately I don't have another machine available to try to SSH to this
laptop. Booting with "nomodeset" works, but then dmesg isn't very useful.

Recent Ubuntu versions don't come with an xorg.conf file, and "sudo Xorg
-configure" reports a fatal error, so I'm not sure how to generate a base file
to tweak.

I could attach /var/log/Xorg.0.log.old after rebooting from the failed state to
something saner, if this would be useful.

However patch "https://bugs.freedesktop.org/attachment.cgi?id=66876"; attached
to bug #54129 appears to fix this bug too, so the above are probably moot.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


[Bug 54649] Image in Quake 3 is dark

2012-09-09 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=54649

JS  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||NOTOURBUG

--- Comment #2 from JS  2012-09-09 13:47:43 UTC ---
it is possible

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.


glapi/libdricore linking trouble with make install targets

2012-09-09 Thread Laurent Carlier
Le dimanche 9 septembre 2012 09:48:54 Andreas Radke a ?crit :
> When building packages in ArchLinux we try to avoid the old
> bin/minstall to move each and every file by hand. So we try to move to
> make install targets. Here we run into several linking issues:
> 
>   make -C src/glx DESTDIR="${pkgdir}" install
> 
> fails with:
> 
> make[2]: Entering directory
> `/build/src/mesa-41d14eaf193c6b1eb87fe1998808a887f1c6c698/src/glx' make[2]:
> Nothing to be done for `install-data-am'.
>  /usr/bin/mkdir -p '/build/pkg/libgl/usr/lib'
>  /bin/sh ../../libtool   --mode=install /usr/bin/install -c   libGL.la
> '/build/pkg/libgl/usr/lib' libtool: install: warning: relinking `libGL.la'
> libtool: install: (cd
> /build/src/mesa-41d14eaf193c6b1eb87fe1998808a887f1c6c698/src/glx; /bin/sh
> /build/src/mesa-41d14eaf193c6b1eb87fe1998808a887f1c6c698/libtool  --silent
> --tag CC --mode=relink gcc -I../../include -I../../include/GL/internal
> -I../../src/mapi -I../../src/mapi/glapi -I../../src/mapi
> -I../../src/mapi/glapi -DGLX_SHARED_GLAPI -DXF86VIDMODE -D_REENTRANT
> -DDEFAULT_DRIVER_DIR=\"/usr/lib/xorg/modules/dri\" -D_GNU_SOURCE -DPTHREADS
> -DTEXTURE_FLOAT_ENABLED -DUSE_X86_64_ASM -DHAVE_DLOPEN
> -DHAVE_POSIX_MEMALIGN -DIN_DRI_DRIVER -DUSE_XCB -DGLX_INDIRECT_RENDERING
> -DGLX_DIRECT_RENDERING -DGLX_USE_TLS -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1
> -DIN_DRI_DRIVER -DHAVE_ALIAS -DHAVE_MINCORE -DHAVE_LIBUDEV
> -DHAVE_LLVM=0x0301 -I/usr/include/libdrm -march=x86-64 -mtune=generic -O2
> -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -Wall
> -std=c99 -Werror=implicit-function-declaration -Werror=missing-prototypes
> -fno-strict-aliasing -fno-builtin-memcmp -Wl,-Bsymbolic -vers ion-number
> 1:2 -no-undefined -Wl,-O1,--sort-common,--as-needed,-z,relro -o libGL.la
> -rpath /usr/lib libglx.la ../../src/mapi/shared-glapi/libglapi.la
> ../../src/mapi/glapi/libglapi.la -lXext -lXdamage -lXfixes -lX11-xcb -lX11
> -lxcb-glx -lxcb -lXxf86vm -ldrm -lm -lpthread -ldl -inst-prefix-dir
> /build/pkg/libgl) /usr/bin/ld: cannot find -lglapi
> collect2: error: ld returned 1 exit status
> libtool: install: error: relink `libGL.la' with the above command before
> installing it make[2]: *** [install-libLTLIBRARIES] Error 1
> 
> 
> Similar errors happen with other targets. Our community found
> a workaround by running this:
> 
>   # fix linking because of splitted package
>   make -C src/mapi/shared-glapi DESTDIR="${pkgdir}" install
> 
>   # libGL & libdricore
>   make -C src/glx DESTDIR="${pkgdir}" install
>   make -C src/mesa/libdricore DESTDIR="${pkgdir}" install
> 
>   # fix linking because of splitted package - cleanup
>   make -C src/mapi/shared-glapi DESTDIR="${pkgdir}" uninstall
> 
> 
> 
> Such step seems to be needed for these other target directories:
> 
> * make -C src/egl DESTDIR="${pkgdir}" install
> * make -C src/gbm DESTDIR="${pkgdir}" install
> 
> Similar issues seem to be there when trying to install the driver targets
> (intel, ati and nouveau), the workaround seems to be then:
> 
>   # fix linking because of splitted package
>   make -C src/mesa/libdricore DESTDIR="${pkgdir}" install
> 
>   make -C src/mesa/drivers/dri/i915 DESTDIR="${pkgdir}" install
>   make -C src/mesa/drivers/dri/i965 DESTDIR="${pkgdir}" install
> 
>   # fix linking because of splitted package - cleanup
>   make -C src/mesa/libdricore DESTDIR="${pkgdir}" uninstall
> 
> 
> Can't these targets do proper linking on their own?
> 
> -Andy
> ArchLinux
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

See https://bugs.freedesktop.org/show_bug.cgi?id=52435

++
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20120909/c6b00274/attachment-0001.html>
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: 
<http://lists.freedesktop.org/archives/dri-devel/attachments/20120909/c6b00274/attachment-0001.pgp>


[Bug 54696] New: unstable frame rate in Quake 3

2012-09-09 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=54696

 Bug #: 54696
   Summary: unstable frame rate in Quake 3
Classification: Unclassified
   Product: Mesa
   Version: git
  Platform: Other
OS/Version: All
Status: NEW
  Severity: major
  Priority: medium
 Component: Drivers/Gallium/i915g
AssignedTo: dri-devel at lists.freedesktop.org
ReportedBy: js314592 at gmail.com


average frame rate in demo four is 50 fps, but while playing online game often
reminds slide show - frame rate is between 5 and 60 fps
using classic i915 driver frame rate is more stable, but average is lower

name of display: :0.0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, 
GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer, 
GLX_OML_swap_method, GLX_SGI_swap_control, GLX_SGIS_multisample, 
GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, 
GLX_INTEL_swap_event
client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
client glx extensions:
GLX_ARB_create_context, GLX_ARB_create_context_profile, 
GLX_ARB_create_context_robustness, GLX_ARB_get_proc_address, 
GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_visual_info, 
GLX_EXT_visual_rating, GLX_EXT_framebuffer_sRGB, 
GLX_EXT_create_context_es2_profile, GLX_MESA_copy_sub_buffer, 
GLX_MESA_multithread_makecurrent, GLX_MESA_swap_control, 
GLX_OML_swap_method, GLX_OML_sync_control, GLX_SGI_make_current_read, 
GLX_SGI_swap_control, GLX_SGI_video_sync, GLX_SGIS_multisample, 
GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, 
GLX_EXT_texture_from_pixmap, GLX_INTEL_swap_event
GLX version: 1.4
GLX extensions:
GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_import_context, 
GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer, 
GLX_MESA_multithread_makecurrent, GLX_MESA_swap_control, 
GLX_OML_swap_method, GLX_OML_sync_control, GLX_SGI_make_current_read, 
GLX_SGI_swap_control, GLX_SGI_video_sync, GLX_SGIS_multisample, 
GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, 
GLX_EXT_texture_from_pixmap
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: Gallium 0.4 on i915 (chipset: G33)
OpenGL version string: 2.1 Mesa 9.0-devel
OpenGL shading language version string: 1.20
OpenGL extensions:
GL_ARB_multisample, GL_EXT_abgr, GL_EXT_bgra, GL_EXT_blend_color, 
GL_EXT_blend_minmax, GL_EXT_blend_subtract, GL_EXT_copy_texture, 
GL_EXT_polygon_offset, GL_EXT_subtexture, GL_EXT_texture_object, 
GL_EXT_vertex_array, GL_EXT_compiled_vertex_array, GL_EXT_texture, 
GL_EXT_texture3D, GL_IBM_rasterpos_clip, GL_ARB_point_parameters, 
GL_EXT_draw_range_elements, GL_EXT_packed_pixels, GL_EXT_point_parameters, 
GL_EXT_rescale_normal, GL_EXT_separate_specular_color, 
GL_EXT_texture_edge_clamp, GL_SGIS_generate_mipmap, 
GL_SGIS_texture_border_clamp, GL_SGIS_texture_edge_clamp, 
GL_SGIS_texture_lod, GL_ARB_multitexture, GL_IBM_multimode_draw_arrays, 
GL_IBM_texture_mirrored_repeat, GL_ARB_texture_cube_map, 
GL_ARB_texture_env_add, GL_ARB_transpose_matrix, 
GL_EXT_blend_func_separate, GL_EXT_fog_coord, GL_EXT_multi_draw_arrays, 
GL_EXT_secondary_color, GL_EXT_texture_env_add, 
GL_EXT_texture_filter_anisotropic, GL_EXT_texture_lod_bias, 
GL_INGR_blend_func_separate, GL_NV_blend_square, GL_NV_light_max_exponent, 
GL_NV_texgen_reflection, GL_NV_texture_env_combine4, 
GL_SUN_multi_draw_arrays, GL_ARB_texture_border_clamp, 
GL_ARB_texture_compression, GL_EXT_framebuffer_object, 
GL_EXT_texture_env_combine, GL_EXT_texture_env_dot3, GL_MESA_window_pos, 
GL_NV_packed_depth_stencil, GL_NV_texture_rectangle, GL_ARB_depth_texture, 
GL_ARB_occlusion_query, GL_ARB_shadow, GL_ARB_texture_env_combine, 
GL_ARB_texture_env_crossbar, GL_ARB_texture_env_dot3, 
GL_ARB_texture_mirrored_repeat, GL_ARB_window_pos, 
GL_EXT_stencil_two_side, GL_EXT_texture_cube_map, GL_NV_fog_distance, 
GL_APPLE_packed_pixels, GL_APPLE_vertex_array_object, GL_ARB_draw_buffers, 
GL_ARB_fragment_program, GL_ARB_fragment_shader, GL_ARB_shader_objects, 
GL_ARB_vertex_program, GL_ARB_vertex_shader, GL_ATI_draw_buffers, 
GL_ATI_texture_env_combine3, GL_EXT_shadow_funcs, GL_EXT_stencil_wrap, 
GL_MESA_pack_invert, GL_MESA_ycbcr_texture, GL_NV_primitive_restart, 
GL_ARB_fragment_program_shadow, GL_ARB_half_float_pixel, 
GL_ARB_occlusion_query2, GL_ARB_point_sprite, GL_ARB_shading_language_100, 
GL_ARB_sync, GL_ARB_texture_non_power_of_two, GL_ARB_vertex_buffer_object, 
GL_ATI_blend_equation_separate, GL_EXT_blend_equation_separate, 
GL_OES_read_format, GL_ARB_pixel_buffer

[RFC] Unified DRM GPU frequency knobs

2012-09-09 Thread Ben Widawsky
On the Intel driver we've developed and reviewed some patches which
enable GPU frequency settings in sysfs. Similar interfaces have existed
for some time in our debugfs, but now we're getting interest from users
like PowerTOP and have decided to formalize it. Most likely other DRM
drivers have similar features; and perhaps similar proposals have gone
out in the past.

Boiling down what we've exposed in our patches:
read current GPU frequency
read/write min frequency
read/write max frequency
read HW support lowest frequency (we call this RPn)
read HW supported highest frequency (we call this RP0)
read HW recommended low frequnecy (we call this RP1)

If no interest is perceived we will move forward with these as Intel
only sysfs interfaces.

The Intel specific patches which are ready to go are here:
http://lists.freedesktop.org/archives/intel-gfx/2012-September/020342.html

Thanks.

-- 
Ben Widawsky, Intel Open Source Technology Center


[RFC] Unified DRM GPU frequency knobs

2012-09-09 Thread Ben Widawsky
On Sun, 9 Sep 2012 12:42:55 -0700
Ben Widawsky  wrote:

> On the Intel driver we've developed and reviewed some patches which
> enable GPU frequency settings in sysfs. Similar interfaces have
> existed for some time in our debugfs, but now we're getting interest
> from users like PowerTOP and have decided to formalize it. Most
> likely other DRM drivers have similar features; and perhaps similar
> proposals have gone out in the past.
> 
> Boiling down what we've exposed in our patches:
> read current GPU frequency
> read/write min frequency
> read/write max frequency
> read HW support lowest frequency (we call this RPn)
> read HW supported highest frequency (we call this RP0)
> read HW recommended low frequnecy (we call this RP1)
> 
> If no interest is perceived we will move forward with these as Intel
> only sysfs interfaces.
> 
> The Intel specific patches which are ready to go are here:
> http://lists.freedesktop.org/archives/intel-gfx/2012-September/020342.html
> 
> Thanks.
> 

I was called out for not being clear. I'm asking if there
is interest in making unified knobs in DRM as opposed to driver specific
knobs. Is that even a good idea, and/or make sense to do?



-- 
Ben Widawsky, Intel Open Source Technology Center


[PATCH] drm: remove property_blob_list

2012-09-09 Thread Rob Clark
On Fri, Sep 7, 2012 at 9:38 PM, Rob Clark  wrote:
> From: Rob Clark 
>
> It isn't used anywhere.

duh, nevermind.. I figured out how it is used.  But maybe I'll add a comment.

BR,
-R

> Signed-off-by: Rob Clark 
> ---
>  drivers/gpu/drm/drm_crtc.c |2 --
>  include/drm/drm_crtc.h |1 -
>  2 files changed, 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 7552675..21a0a85 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -995,7 +995,6 @@ void drm_mode_config_init(struct drm_device *dev)
> INIT_LIST_HEAD(&dev->mode_config.connector_list);
> INIT_LIST_HEAD(&dev->mode_config.encoder_list);
> INIT_LIST_HEAD(&dev->mode_config.property_list);
> -   INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
> INIT_LIST_HEAD(&dev->mode_config.plane_list);
> idr_init(&dev->mode_config.crtc_idr);
>
> @@ -3114,7 +3113,6 @@ static struct drm_property_blob 
> *drm_property_create_blob(struct drm_device *dev
>
> memcpy(blob->data, data, length);
>
> -   list_add_tail(&blob->head, &dev->mode_config.property_blob_list);
> return blob;
>  }
>
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 1422b36..a3574d0d 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -794,7 +794,6 @@ struct drm_mode_config {
> struct delayed_work output_poll_work;
>
> /* pointers to standard properties */
> -   struct list_head property_blob_list;
> struct drm_property *edid_property;
> struct drm_property *dpms_property;
>
> --
> 1.7.9.5
>


[RFC 0/9] nuclear pageflip

2012-09-09 Thread Rob Clark
From: Rob Clark 

This is following a bit the approach that Ville is taking for atomic-
modeset, in that it is switching over to using properties for everything.
The advantage of this approach is that it makes it easier to add new
attributes to set as part of a page-flip (and even opens the option to
add new object types).

The basic principles are:
 a) split out object state (in this case, plane and crtc, although I
expect more to be added as atomic-modeset is added) into seperate
structures that can be atomically commited or rolled back
 b) expand the object property API (set_property()) to take a state
object.  The obj->set_property() simply updates the state object
without actually applying the changes to the hw.
 c) after all the property updates are done, the updated state can
be checked for correctness and against the hw capabilities, and
then either discarded or committed atomically.

Since we need to include properties in the nuclear-pageflip scheme,
doing everything via properties avoids updating a bunch of additional
driver provided callbacks.  Instead we just drop crtc->page_flip()
and plane->update_plane().  By splitting out the object's mutable
state into drm_{plane,crtc,etc}_state structs (which are wrapped by
the individual drivers to add their own hw specific state), we can
use some helpers (drm_{plane,crtc,etc}_set_property() and
drm_{plane,crtc,etc}_check_state()) to keep core error checking in
drm core and avoid pushing the burden of dealing with common
properties to the individual drivers.

So far, I've only updated omapdrm to the new APIs, as a proof of
concept.  Only a few drivers support drm plane, so I expect the
updates to convert drm-plane to properties should not be so hard.
Possibly for crtc/pageflip we might need to have a transition period
where we still support crtc->page_flip() code path until all drivers
are updated.

My complete branch is here:

  https://github.com/robclark/kernel-omap4/commits/drm_nuclear
  git://github.com/robclark/kernel-omap4.git drm_nuclear

Rob Clark (9):
  drm: add atomic fxns
  drm: add object property type
  drm: add DRM_MODE_PROP_DYNAMIC property flag
  drm: convert plane to properties
  drm: add drm_plane_state
  drm: convert page_flip to properties
  drm: add drm_crtc_state
  drm: nuclear pageflip
  drm/omap: update for atomic age

 drivers/gpu/drm/drm_crtc.c|  769 +++--
 drivers/gpu/drm/drm_crtc_helper.c |   51 +--
 drivers/gpu/drm/drm_drv.c |1 +
 drivers/gpu/drm/drm_fb_helper.c   |   11 +-
 drivers/staging/omapdrm/Makefile  |1 +
 drivers/staging/omapdrm/omap_atomic.c |  270 
 drivers/staging/omapdrm/omap_atomic.h |   52 +++
 drivers/staging/omapdrm/omap_crtc.c   |  247 +--
 drivers/staging/omapdrm/omap_drv.c|5 +
 drivers/staging/omapdrm/omap_drv.h|   35 +-
 drivers/staging/omapdrm/omap_fb.c |   44 +-
 drivers/staging/omapdrm/omap_plane.c  |  270 ++--
 include/drm/drm.h |2 +
 include/drm/drmP.h|   32 ++
 include/drm/drm_crtc.h|  140 --
 include/drm/drm_mode.h|   48 ++
 16 files changed, 1378 insertions(+), 600 deletions(-)
 create mode 100644 drivers/staging/omapdrm/omap_atomic.c
 create mode 100644 drivers/staging/omapdrm/omap_atomic.h

-- 
1.7.9.5



[RFC 1/9] drm: add atomic fxns

2012-09-09 Thread Rob Clark
From: Rob Clark 

The 'atomic' mechanism allows for multiple properties to be updated,
checked, and commited atomically.  This will be the basis of atomic-
modeset and nuclear-pageflip.

The basic flow is:

   state = dev->atomic_begin();
   for (... one or more ...)
  obj->set_property(obj, state, prop, value);
   if (dev->atomic_check(state))
  dev->atomic_commit(state, event);
   dev->atomic_end(state);

The split of check and commit steps is to allow for ioctls with a
test-only flag (which would skip the commit step).

The atomic functions are mandatory, as they will end up getting
called from enough places that it is easier not to have to bother
with if-null checks everywhere.

TODO:
  + add some stub atomic functions that can be used by drivers
until they are updated to support atomic operations natively
  + roll-back previous property values if check/commit fails, so
userspace doesn't see incorrect values.
---
 drivers/gpu/drm/drm_crtc.c |  126 +++-
 include/drm/drmP.h |   32 +++
 include/drm/drm_crtc.h |8 +--
 3 files changed, 115 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 7552675..40a3f21 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3227,12 +3227,11 @@ int drm_mode_connector_property_set_ioctl(struct 
drm_device *dev,
return drm_mode_obj_set_property_ioctl(dev, &obj_set_prop, file_priv);
 }

-static int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
-  struct drm_property *property,
+static int drm_mode_connector_set_obj_prop(struct drm_connector *connector,
+  void *state, struct drm_property 
*property,
   uint64_t value)
 {
int ret = -EINVAL;
-   struct drm_connector *connector = obj_to_connector(obj);

/* Do DPMS ourselves */
if (property == connector->dev->mode_config.dpms_property) {
@@ -3240,7 +3239,7 @@ static int drm_mode_connector_set_obj_prop(struct 
drm_mode_object *obj,
(*connector->funcs->dpms)(connector, (int)value);
ret = 0;
} else if (connector->funcs->set_property)
-   ret = connector->funcs->set_property(connector, property, 
value);
+   ret = connector->funcs->set_property(connector, state, 
property, value);

/* store the property value if successful */
if (!ret)
@@ -3248,36 +3247,87 @@ static int drm_mode_connector_set_obj_prop(struct 
drm_mode_object *obj,
return ret;
 }

-static int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj,
- struct drm_property *property,
+static int drm_mode_crtc_set_obj_prop(struct drm_crtc *crtc,
+ void *state, struct drm_property 
*property,
  uint64_t value)
 {
int ret = -EINVAL;
-   struct drm_crtc *crtc = obj_to_crtc(obj);

if (crtc->funcs->set_property)
-   ret = crtc->funcs->set_property(crtc, property, value);
+   ret = crtc->funcs->set_property(crtc, state, property, value);
if (!ret)
-   drm_object_property_set_value(obj, property, value);
+   drm_object_property_set_value(&crtc->base, property, value);

return ret;
 }

-static int drm_mode_plane_set_obj_prop(struct drm_mode_object *obj,
- struct drm_property *property,
+static int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
+ void *state, struct drm_property 
*property,
  uint64_t value)
 {
int ret = -EINVAL;
-   struct drm_plane *plane = obj_to_plane(obj);

if (plane->funcs->set_property)
-   ret = plane->funcs->set_property(plane, property, value);
+   ret = plane->funcs->set_property(plane, state, property, value);
if (!ret)
-   drm_object_property_set_value(obj, property, value);
+   drm_object_property_set_value(&plane->base, property, value);

return ret;
 }

+static int drm_mode_set_obj_prop(struct drm_device *dev,
+   struct drm_mode_object *obj, void *state,
+   struct drm_property *property, uint64_t value)
+{
+   if (drm_property_change_is_valid(property, value)) {
+   switch (obj->type) {
+   case DRM_MODE_OBJECT_CONNECTOR:
+   return 
drm_mode_connector_set_obj_prop(obj_to_connector(obj),
+   state, property, value);
+   case DRM_MODE_OBJECT_CRTC:
+   return drm_mode_crtc_set_obj_prop(obj_to_crtc(obj),
+   state, property, value);
+   case DRM_MODE_OBJECT_PLANE:
+

[RFC 2/9] drm: add object property type

2012-09-09 Thread Rob Clark
From: Rob Clark 

An object property is an id (idr) for a drm mode object.  This
will allow a property to be used set/get a framebuffer, CRTC, etc.
---
 drivers/gpu/drm/drm_crtc.c |   28 
 include/drm/drm_crtc.h |5 +
 include/drm/drm_mode.h |1 +
 3 files changed, 34 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 40a3f21..12829de 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2859,6 +2859,23 @@ struct drm_property *drm_property_create_range(struct 
drm_device *dev, int flags
 }
 EXPORT_SYMBOL(drm_property_create_range);

+struct drm_property *drm_property_create_object(struct drm_device *dev,
+int flags, const char *name, uint32_t 
type)
+{
+   struct drm_property *property;
+
+   flags |= DRM_MODE_PROP_OBJECT;
+
+   property = drm_property_create(dev, flags, name, 1);
+   if (!property)
+   return NULL;
+
+   property->values[0] = type;
+
+   return property;
+}
+EXPORT_SYMBOL(drm_property_create_object);
+
 int drm_property_add_enum(struct drm_property *property, int index,
  uint64_t value, const char *name)
 {
@@ -3203,6 +3220,9 @@ static bool drm_property_change_is_valid(struct 
drm_property *property,
for (i = 0; i < property->num_values; i++)
valid_mask |= (1ULL << property->values[i]);
return !(value & ~valid_mask);
+   } else if (property->flags & DRM_MODE_PROP_OBJECT) {
+   /* check for valid object or zero happens elsewhere */
+   return true;
} else {
int i;
for (i = 0; i < property->num_values; i++)
@@ -3280,6 +3300,14 @@ static int drm_mode_set_obj_prop(struct drm_device *dev,
struct drm_property *property, uint64_t value)
 {
if (drm_property_change_is_valid(property, value)) {
+   /* a zero value for an object property translates to null: */
+   if ((property->flags & DRM_MODE_PROP_OBJECT) && value) {
+   struct drm_mode_object *obj =
+   drm_mode_object_find(dev, value, 
property->values[0]);
+   if (!obj)
+   return -EINVAL;
+   value = VOID2U64(obj);
+   }
switch (obj->type) {
case DRM_MODE_OBJECT_CONNECTOR:
return 
drm_mode_connector_set_obj_prop(obj_to_connector(obj),
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index a609190..92df2f4 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -61,6 +61,9 @@ struct drm_object_properties {
uint64_t values[DRM_OBJECT_MAX_PROPERTY];
 };

+#define U642VOID(x) ((void *)(unsigned long)(x))
+#define VOID2U64(x) ((uint64_t)(unsigned long)(x))
+
 /*
  * Note on terminology:  here, for brevity and convenience, we refer to 
connector
  * control chips as 'CRTCs'.  They can control any type of connector, VGA, 
LVDS,
@@ -955,6 +958,8 @@ struct drm_property *drm_property_create_bitmask(struct 
drm_device *dev,
 struct drm_property *drm_property_create_range(struct drm_device *dev, int 
flags,
 const char *name,
 uint64_t min, uint64_t max);
+struct drm_property *drm_property_create_object(struct drm_device *dev,
+int flags, const char *name, uint32_t 
type);
 extern void drm_property_destroy(struct drm_device *dev, struct drm_property 
*property);
 extern int drm_property_add_enum(struct drm_property *property, int index,
 uint64_t value, const char *name);
diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
index 5581980..cee4c53 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -231,6 +231,7 @@ struct drm_mode_get_connector {
 #define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */
 #define DRM_MODE_PROP_BLOB (1<<4)
 #define DRM_MODE_PROP_BITMASK  (1<<5) /* bitmask of enumerated types */
+#define DRM_MODE_PROP_OBJECT   (1<<6) /* drm mode object */

 struct drm_mode_property_enum {
__u64 value;
-- 
1.7.9.5



[RFC 3/9] drm: add DRM_MODE_PROP_DYNAMIC property flag

2012-09-09 Thread Rob Clark
From: Rob Clark 

This indicates to userspace that the property is something that can
be set dynamically without requiring a "test" step to check if the
hw is capable.  This allows a userspace compositor, such as weston,
to avoid an extra ioctl to check whether it needs to fall-back to
GPU to composite some surface prior to submission of GPU render
commands.
---
 include/drm/drm_mode.h |9 +
 1 file changed, 9 insertions(+)

diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
index cee4c53..8cec2cf 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -232,6 +232,15 @@ struct drm_mode_get_connector {
 #define DRM_MODE_PROP_BLOB (1<<4)
 #define DRM_MODE_PROP_BITMASK  (1<<5) /* bitmask of enumerated types */
 #define DRM_MODE_PROP_OBJECT   (1<<6) /* drm mode object */
+/* Properties that are not dynamic cannot safely be changed without a
+ * atomic-modeset / nuclear-pageflip test step.  But if userspace is
+ * only changing dynamic properties, it is garanteed that the change
+ * will not exceed hw limits, so no test step is required.
+ *
+ * Note that fb_id properties are a bit ambiguous.. they of course can
+ * be changed dynamically, assuming the pixel format does not change.
+ */
+#define DRM_MODE_PROP_DYNAMIC  (1<<24)

 struct drm_mode_property_enum {
__u64 value;
-- 
1.7.9.5



[RFC 4/9] drm: convert plane to properties

2012-09-09 Thread Rob Clark
From: Rob Clark 

Use atomic properties mechanism to set plane attributes.  This by
itself doesn't accomplish anything, but it avoids having multiple
code paths to do the same thing when nuclear-pageflip and atomic-
modeset are introduced.
---
 drivers/gpu/drm/drm_crtc.c |  270 ++--
 include/drm/drm_crtc.h |   32 --
 2 files changed, 187 insertions(+), 115 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 12829de..e680fbe 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -38,6 +38,10 @@
 #include "drm_edid.h"
 #include "drm_fourcc.h"

+static int drm_mode_set_obj_prop(struct drm_device *dev,
+   struct drm_mode_object *obj, void *state,
+   struct drm_property *property, uint64_t value);
+
 /* Avoid boilerplate.  I'm tired of typing. */
 #define DRM_ENUM_NAME_FN(fnname, list) \
char *fnname(int val)   \
@@ -380,11 +384,19 @@ EXPORT_SYMBOL(drm_framebuffer_cleanup);
 void drm_framebuffer_remove(struct drm_framebuffer *fb)
 {
struct drm_device *dev = fb->dev;
+   struct drm_mode_config *config = &dev->mode_config;
struct drm_crtc *crtc;
struct drm_plane *plane;
struct drm_mode_set set;
+   void *state;
int ret;

+   state = dev->driver->atomic_begin(dev);
+   if (IS_ERR(state)) {
+   DRM_ERROR("failed to disable crtc and/or plane when fb was 
deleted\n");
+   return;
+   }
+
/* remove from any CRTC */
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
if (crtc->fb == fb) {
@@ -401,15 +413,19 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
list_for_each_entry(plane, &dev->mode_config.plane_list, head) {
if (plane->fb == fb) {
/* should turn off the crtc */
-   ret = plane->funcs->disable_plane(plane);
-   if (ret)
-   DRM_ERROR("failed to disable plane with busy 
fb\n");
-   /* disconnect the plane from the fb and crtc: */
-   plane->fb = NULL;
-   plane->crtc = NULL;
+   drm_mode_plane_set_obj_prop(plane, state, 
config->prop_crtc_id, 0);
+   drm_mode_plane_set_obj_prop(plane, state, 
config->prop_fb_id, 0);
}
}

+   /* just disabling stuff shouldn't fail, hopefully: */
+   if(dev->driver->atomic_check(dev, state))
+   DRM_ERROR("failed to disable crtc and/or plane when fb was 
deleted\n");
+   else
+   dev->driver->atomic_commit(dev, state, NULL);
+
+   dev->driver->atomic_end(dev, state);
+
list_del(&fb->filp_head);

drm_framebuffer_unreference(fb);
@@ -661,6 +677,7 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane 
*plane,
   const uint32_t *formats, uint32_t format_count,
   bool priv)
 {
+   struct drm_mode_config *config = &dev->mode_config;
int ret;

mutex_lock(&dev->mode_config.mutex);
@@ -696,6 +713,17 @@ int drm_plane_init(struct drm_device *dev, struct 
drm_plane *plane,
INIT_LIST_HEAD(&plane->head);
}

+   drm_object_attach_property(&plane->base, config->prop_fb_id, 0);
+   drm_object_attach_property(&plane->base, config->prop_crtc_id, 0);
+   drm_object_attach_property(&plane->base, config->prop_crtc_x, 0);
+   drm_object_attach_property(&plane->base, config->prop_crtc_y, 0);
+   drm_object_attach_property(&plane->base, config->prop_crtc_w, 0);
+   drm_object_attach_property(&plane->base, config->prop_crtc_h, 0);
+   drm_object_attach_property(&plane->base, config->prop_src_x, 0);
+   drm_object_attach_property(&plane->base, config->prop_src_y, 0);
+   drm_object_attach_property(&plane->base, config->prop_src_w, 0);
+   drm_object_attach_property(&plane->base, config->prop_src_h, 0);
+
  out:
mutex_unlock(&dev->mode_config.mutex);

@@ -769,23 +797,89 @@ void drm_mode_destroy(struct drm_device *dev, struct 
drm_display_mode *mode)
 }
 EXPORT_SYMBOL(drm_mode_destroy);

-static int drm_mode_create_standard_connector_properties(struct drm_device 
*dev)
+static int drm_mode_create_standard_properties(struct drm_device *dev)
 {
-   struct drm_property *edid;
-   struct drm_property *dpms;
+   struct drm_property *prop;

/*
 * Standard properties (apply to all connectors)
 */
-   edid = drm_property_create(dev, DRM_MODE_PROP_BLOB |
+   prop = drm_property_create(dev, DRM_MODE_PROP_BLOB |
   DRM_MODE_PROP_IMMUTABLE,
   "EDID", 0);
-   dev->mode_config.edid_property = edid;
+   if (!prop)
+   return -ENOMEM;
+   dev->

[RFC 5/9] drm: add drm_plane_state

2012-09-09 Thread Rob Clark
From: Rob Clark 

Break the mutable state of a plane out into a separate structure.
This makes it easier to have some helpers for plane->set_property()
and for checking for invalid params.  The idea is that individual
drivers can wrap the state struct in their own struct which adds
driver specific parameters, for easy build-up of state across
multiple set_property() calls and for easy atomic commit or roll-
back.

The same should be done for CRTC, encoder, and connector, but this
patch only includes the first part (plane).
---
 drivers/gpu/drm/drm_crtc.c |   97 +---
 include/drm/drm_crtc.h |   38 +
 2 files changed, 123 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index e680fbe..ce6fa6a 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -411,7 +411,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
}

list_for_each_entry(plane, &dev->mode_config.plane_list, head) {
-   if (plane->fb == fb) {
+   if (plane->state->fb == fb) {
/* should turn off the crtc */
drm_mode_plane_set_obj_prop(plane, state, 
config->prop_crtc_id, 0);
drm_mode_plane_set_obj_prop(plane, state, 
config->prop_fb_id, 0);
@@ -747,6 +747,93 @@ void drm_plane_cleanup(struct drm_plane *plane)
 }
 EXPORT_SYMBOL(drm_plane_cleanup);

+int drm_plane_check_state(struct drm_plane *plane,
+   struct drm_plane_state *state)
+{
+   unsigned int fb_width, fb_height;
+   struct drm_framebuffer *fb = state->fb;
+   int i;
+
+   fb_width = fb->width << 16;
+   fb_height = fb->height << 16;
+
+   /* Check whether this plane supports the fb pixel format. */
+   for (i = 0; i < plane->format_count; i++)
+   if (fb->pixel_format == plane->format_types[i])
+   break;
+   if (i == plane->format_count) {
+   DRM_DEBUG_KMS("Invalid pixel format 0x%08x\n", 
fb->pixel_format);
+   return -EINVAL;
+   }
+
+   /* Make sure source coordinates are inside the fb. */
+   if (state->src_w > fb_width ||
+   state->src_x > fb_width - state->src_w ||
+   state->src_h > fb_height ||
+   state->src_y > fb_height - state->src_h) {
+   DRM_DEBUG_KMS("Invalid source coordinates "
+ "%u.%06ux%u.%06u+%u.%06u+%u.%06u\n",
+ state->src_w >> 16,
+ ((state->src_w & 0x) * 15625) >> 10,
+ state->src_h >> 16,
+ ((state->src_h & 0x) * 15625) >> 10,
+ state->src_x >> 16,
+ ((state->src_x & 0x) * 15625) >> 10,
+ state->src_y >> 16,
+ ((state->src_y & 0x) * 15625) >> 10);
+   return -ENOSPC;
+   }
+
+   /* Give drivers some help against integer overflows */
+   if (state->crtc_w > INT_MAX ||
+   state->crtc_x > INT_MAX - (int32_t) state->crtc_w ||
+   state->crtc_h > INT_MAX ||
+   state->crtc_y > INT_MAX - (int32_t) state->crtc_h) {
+   DRM_DEBUG_KMS("Invalid CRTC coordinates %ux%u+%d+%d\n",
+ state->crtc_w, state->crtc_h,
+ state->crtc_x, state->crtc_y);
+   return -ERANGE;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_plane_check_state);
+
+int drm_plane_set_property(struct drm_plane *plane,
+   struct drm_plane_state *state,
+   struct drm_property *property, uint64_t value)
+{
+   struct drm_device *dev = plane->dev;
+   struct drm_mode_config *config = &dev->mode_config;
+
+   if (property == config->prop_fb_id) {
+   state->fb = U642VOID(value);
+   } else if (property == config->prop_crtc_id) {
+   state->crtc = U642VOID(value);
+   } else if (property == config->prop_crtc_x) {
+   state->crtc_x = *(int32_t *)&value;
+   } else if (property == config->prop_crtc_y) {
+   state->crtc_y = *(int32_t *)&value;
+   } else if (property == config->prop_crtc_w) {
+   state->crtc_w = value;
+   } else if (property == config->prop_crtc_h) {
+   state->crtc_h = value;
+   } else if (property == config->prop_src_x) {
+   state->src_x = value;
+   } else if (property == config->prop_src_y) {
+   state->src_y = value;
+   } else if (property == config->prop_src_w) {
+   state->src_w = value;
+   } else if (property == config->prop_src_h) {
+   state->src_h = value;
+   } else {
+   return -EINVAL;
+   }
+
+   return 0;
+

[RFC 6/9] drm: convert page_flip to properties

2012-09-09 Thread Rob Clark
From: Rob Clark 

Use atomic properties mechanism for CRTC page_flip.  This by itself
doesn't accomplish anything, but it avoids having multiple code
paths to do the same thing when nuclear-pageflip and atomic-modeset
are introduced.
---
 drivers/gpu/drm/drm_crtc.c |   59 +---
 include/drm/drm_crtc.h |   13 --
 2 files changed, 23 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index ce6fa6a..8be57e4 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -387,9 +387,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
struct drm_mode_config *config = &dev->mode_config;
struct drm_crtc *crtc;
struct drm_plane *plane;
-   struct drm_mode_set set;
void *state;
-   int ret;

state = dev->driver->atomic_begin(dev);
if (IS_ERR(state)) {
@@ -401,12 +399,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
if (crtc->fb == fb) {
/* should turn off the crtc */
-   memset(&set, 0, sizeof(struct drm_mode_set));
-   set.crtc = crtc;
-   set.fb = NULL;
-   ret = crtc->funcs->set_config(&set);
-   if (ret)
-   DRM_ERROR("failed to reset crtc %p when fb was 
deleted\n", crtc);
+   drm_mode_crtc_set_obj_prop(crtc, state, 
config->prop_crtc_id, 0);
}
}

@@ -449,6 +442,7 @@ EXPORT_SYMBOL(drm_framebuffer_remove);
 int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
   const struct drm_crtc_funcs *funcs)
 {
+   struct drm_mode_config *config = &dev->mode_config;
int ret;

crtc->dev = dev;
@@ -466,6 +460,10 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc 
*crtc,
list_add_tail(&crtc->head, &dev->mode_config.crtc_list);
dev->mode_config.num_crtc++;

+   drm_object_attach_property(&crtc->base, config->prop_fb_id, 0);
+   drm_object_attach_property(&crtc->base, config->prop_crtc_x, 0);
+   drm_object_attach_property(&crtc->base, config->prop_crtc_y, 0);
+
  out:
mutex_unlock(&dev->mode_config.mutex);

@@ -3750,12 +3748,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 void *data, struct drm_file *file_priv)
 {
struct drm_mode_crtc_page_flip *page_flip = data;
+   struct drm_mode_config *config = &dev->mode_config;
struct drm_mode_object *obj;
struct drm_crtc *crtc;
-   struct drm_framebuffer *fb;
struct drm_pending_vblank_event *e = NULL;
unsigned long flags;
-   int hdisplay, vdisplay;
+   void *state;
int ret = -EINVAL;

if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS ||
@@ -3763,6 +3761,13 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
return -EINVAL;

mutex_lock(&dev->mode_config.mutex);
+
+   state = dev->driver->atomic_begin(dev);
+   if (IS_ERR(state)) {
+   ret = PTR_ERR(state);
+   goto out_unlock;
+   }
+
obj = drm_mode_object_find(dev, page_flip->crtc_id, 
DRM_MODE_OBJECT_CRTC);
if (!obj)
goto out;
@@ -3777,31 +3782,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
goto out;
}

-   if (crtc->funcs->page_flip == NULL)
-   goto out;
-
-   obj = drm_mode_object_find(dev, page_flip->fb_id, DRM_MODE_OBJECT_FB);
-   if (!obj)
-   goto out;
-   fb = obj_to_fb(obj);
-
-   hdisplay = crtc->mode.hdisplay;
-   vdisplay = crtc->mode.vdisplay;
-
-   if (crtc->invert_dimensions)
-   swap(hdisplay, vdisplay);
-
-   if (hdisplay > fb->width ||
-   vdisplay > fb->height ||
-   crtc->x > fb->width - hdisplay ||
-   crtc->y > fb->height - vdisplay) {
-   DRM_DEBUG_KMS("Invalid fb size %ux%u for CRTC viewport 
%ux%u+%d+%d%s.\n",
- fb->width, fb->height, hdisplay, vdisplay, 
crtc->x, crtc->y,
- crtc->invert_dimensions ? " (inverted)" : "");
-   ret = -ENOSPC;
-   goto out;
-   }
-
if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
ret = -ENOMEM;
spin_lock_irqsave(&dev->event_lock, flags);
@@ -3829,7 +3809,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
(void (*) (struct drm_pending_event *)) kfree;
}

-   ret = crtc->funcs->page_flip(crtc, fb, e);
+   ret = drm_mode_set_obj_prop(dev, obj, state,
+   config->prop_fb_id, page_flip->fb_id);
+   if (ret)
+   goto out;
+
+   ret = dev->driver->atomic_commit(dev, state, e);
   

[RFC 7/9] drm: add drm_crtc_state

2012-09-09 Thread Rob Clark
From: Rob Clark 

Start breaking out the mutable state of the CRTC into it's own
structure.  Plus add _check_state() and _set_property() helpers.
This only moves the state that is related to scanout fb, which
is needed for nuclear-pageflip.  The rest of the mutable state
should be moved from drm_crtc to drm_crtc_state as part of the
atomic-modeset implementation.
---
 drivers/gpu/drm/drm_crtc.c|   70 +++--
 drivers/gpu/drm/drm_crtc_helper.c |   51 ++-
 drivers/gpu/drm/drm_fb_helper.c   |   11 +++---
 include/drm/drm_crtc.h|   44 +--
 4 files changed, 125 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 8be57e4..0ddd43e 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -397,7 +397,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)

/* remove from any CRTC */
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-   if (crtc->fb == fb) {
+   if (crtc->state->fb == fb) {
/* should turn off the crtc */
drm_mode_crtc_set_obj_prop(crtc, state, 
config->prop_crtc_id, 0);
}
@@ -447,7 +447,7 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc 
*crtc,

crtc->dev = dev;
crtc->funcs = funcs;
-   crtc->invert_dimensions = false;
+   crtc->state->invert_dimensions = false;

mutex_lock(&dev->mode_config.mutex);

@@ -496,6 +496,54 @@ void drm_crtc_cleanup(struct drm_crtc *crtc)
 }
 EXPORT_SYMBOL(drm_crtc_cleanup);

+int drm_crtc_check_state(struct drm_crtc *crtc,
+   struct drm_crtc_state *state)
+{
+   struct drm_framebuffer *fb = state->fb;
+   int hdisplay, vdisplay;
+
+   hdisplay = crtc->mode.hdisplay;
+   vdisplay = crtc->mode.vdisplay;
+
+   if (state->invert_dimensions)
+   swap(hdisplay, vdisplay);
+
+   if (hdisplay > fb->width ||
+   vdisplay > fb->height ||
+   state->x > fb->width - hdisplay ||
+   state->y > fb->height - vdisplay) {
+   DRM_DEBUG_KMS("Invalid fb size %ux%u for CRTC viewport 
%ux%u+%d+%d%s.\n",
+ fb->width, fb->height, hdisplay, vdisplay,
+ state->x, state->y,
+ state->invert_dimensions ? " (inverted)" : "");
+   return -ENOSPC;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_crtc_check_state);
+
+int drm_crtc_set_property(struct drm_crtc *crtc,
+   struct drm_crtc_state *state,
+   struct drm_property *property, uint64_t value)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_mode_config *config = &dev->mode_config;
+
+   if (property == config->prop_fb_id) {
+   state->fb = U642VOID(value);
+   } else if (property == config->prop_crtc_x) {
+   state->x = *(int *)&value;
+   } else if (property == config->prop_crtc_y) {
+   state->y = *(int32_t *)&value;
+   } else {
+   return -EINVAL;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_crtc_set_property);
+
 /**
  * drm_mode_probed_add - add a mode to a connector's probed mode list
  * @connector: connector the new mode
@@ -1593,11 +1641,11 @@ int drm_mode_getcrtc(struct drm_device *dev,
}
crtc = obj_to_crtc(obj);

-   crtc_resp->x = crtc->x;
-   crtc_resp->y = crtc->y;
+   crtc_resp->x = crtc->state->x;
+   crtc_resp->y = crtc->state->y;
crtc_resp->gamma_size = crtc->gamma_size;
-   if (crtc->fb)
-   crtc_resp->fb_id = crtc->fb->base.id;
+   if (crtc->state->fb)
+   crtc_resp->fb_id = crtc->state->fb->base.id;
else
crtc_resp->fb_id = 0;

@@ -2042,12 +2090,12 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
/* If we have a mode we need a framebuffer. */
/* If we pass -1, set the mode with the currently bound fb */
if (crtc_req->fb_id == -1) {
-   if (!crtc->fb) {
+   if (!crtc->state->fb) {
DRM_DEBUG_KMS("CRTC doesn't have current FB\n");
ret = -EINVAL;
goto out;
}
-   fb = crtc->fb;
+   fb = crtc->state->fb;
} else {
obj = drm_mode_object_find(dev, crtc_req->fb_id,
   DRM_MODE_OBJECT_FB);
@@ -2077,7 +2125,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
hdisplay = mode->hdisplay;
vdisplay = mode->vdisplay;

-   if (crtc->invert_dimensions)
+   if (crtc->state->invert_dimensions)
swap(hdisplay

[RFC 8/9] drm: nuclear pageflip

2012-09-09 Thread Rob Clark
From: Rob Clark 

---
 drivers/gpu/drm/drm_crtc.c |  147 +++-
 drivers/gpu/drm/drm_drv.c  |1 +
 include/drm/drm.h  |2 +
 include/drm/drm_crtc.h |2 +
 include/drm/drm_mode.h |   38 
 5 files changed, 161 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 0ddd43e..d285b11 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3792,6 +3792,51 @@ out:
return ret;
 }

+static struct drm_pending_vblank_event *create_vblank_event(
+   struct drm_device *dev, struct drm_file *file_priv, uint64_t 
user_data)
+{
+   struct drm_pending_vblank_event *e = NULL;
+   unsigned long flags;
+
+   spin_lock_irqsave(&dev->event_lock, flags);
+   if (file_priv->event_space < sizeof e->event) {
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+   goto out;
+   }
+   file_priv->event_space -= sizeof e->event;
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+
+   e = kzalloc(sizeof *e, GFP_KERNEL);
+   if (e == NULL) {
+   spin_lock_irqsave(&dev->event_lock, flags);
+   file_priv->event_space += sizeof e->event;
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+   goto out;
+   }
+
+   e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
+   e->event.base.length = sizeof e->event;
+   e->event.user_data = user_data;
+   e->base.event = &e->event.base;
+   e->base.file_priv = file_priv;
+   e->base.destroy =
+   (void (*) (struct drm_pending_event *)) kfree;
+
+out:
+   return e;
+}
+
+static void destroy_vblank_event(struct drm_device *dev,
+   struct drm_file *file_priv, struct drm_pending_vblank_event *e)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(&dev->event_lock, flags);
+   file_priv->event_space += sizeof e->event;
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+   kfree(e);
+}
+
 int drm_mode_page_flip_ioctl(struct drm_device *dev,
 void *data, struct drm_file *file_priv)
 {
@@ -3800,7 +3845,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
struct drm_mode_object *obj;
struct drm_crtc *crtc;
struct drm_pending_vblank_event *e = NULL;
-   unsigned long flags;
void *state;
int ret = -EINVAL;

@@ -3831,30 +3875,11 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
}

if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
-   ret = -ENOMEM;
-   spin_lock_irqsave(&dev->event_lock, flags);
-   if (file_priv->event_space < sizeof e->event) {
-   spin_unlock_irqrestore(&dev->event_lock, flags);
-   goto out;
-   }
-   file_priv->event_space -= sizeof e->event;
-   spin_unlock_irqrestore(&dev->event_lock, flags);
-
-   e = kzalloc(sizeof *e, GFP_KERNEL);
-   if (e == NULL) {
-   spin_lock_irqsave(&dev->event_lock, flags);
-   file_priv->event_space += sizeof e->event;
-   spin_unlock_irqrestore(&dev->event_lock, flags);
+   e = create_vblank_event(dev, file_priv, page_flip->user_data);
+   if (!e) {
+   ret = -ENOMEM;
goto out;
}
-
-   e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
-   e->event.base.length = sizeof e->event;
-   e->event.user_data = page_flip->user_data;
-   e->base.event = &e->event.base;
-   e->base.file_priv = file_priv;
-   e->base.destroy =
-   (void (*) (struct drm_pending_event *)) kfree;
}

ret = drm_mode_set_obj_prop(dev, obj, state,
@@ -3863,15 +3888,79 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
goto out;

ret = dev->driver->atomic_commit(dev, state, e);
-   if (ret) {
-   if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
-   spin_lock_irqsave(&dev->event_lock, flags);
-   file_priv->event_space += sizeof e->event;
-   spin_unlock_irqrestore(&dev->event_lock, flags);
-   kfree(e);
+   if (ret && e)
+   destroy_vblank_event(dev, file_priv, e);
+
+out:
+   dev->driver->atomic_end(dev, state);
+out_unlock:
+   mutex_unlock(&dev->mode_config.mutex);
+   return ret;
+}
+
+int drm_mode_nuclear_page_flip_ioctl(struct drm_device *dev,
+void *data, struct drm_file *file_priv)
+{
+   struct drm_mode_crtc_nuclear_page_flip *page_flip = data;
+   struct drm_mode_obj_set_property __user *props =
+   (struct drm_mode_obj_set_property __user *)
+  

[RFC 9/9] drm/omap: update for atomic age

2012-09-09 Thread Rob Clark
From: Rob Clark 

---
 drivers/staging/omapdrm/Makefile  |1 +
 drivers/staging/omapdrm/omap_atomic.c |  270 +
 drivers/staging/omapdrm/omap_atomic.h |   52 +++
 drivers/staging/omapdrm/omap_crtc.c   |  247 +-
 drivers/staging/omapdrm/omap_drv.c|5 +
 drivers/staging/omapdrm/omap_drv.h|   35 +++--
 drivers/staging/omapdrm/omap_fb.c |   44 +++---
 drivers/staging/omapdrm/omap_plane.c  |  270 +
 8 files changed, 616 insertions(+), 308 deletions(-)
 create mode 100644 drivers/staging/omapdrm/omap_atomic.c
 create mode 100644 drivers/staging/omapdrm/omap_atomic.h

diff --git a/drivers/staging/omapdrm/Makefile b/drivers/staging/omapdrm/Makefile
index d85e058..7d45e4d 100644
--- a/drivers/staging/omapdrm/Makefile
+++ b/drivers/staging/omapdrm/Makefile
@@ -13,6 +13,7 @@ omapdrm-y := omap_drv.o \
omap_connector.o \
omap_fb.o \
omap_fbdev.o \
+   omap_atomic.o \
omap_gem.o \
omap_gem_dmabuf.o \
omap_dmm_tiler.o \
diff --git a/drivers/staging/omapdrm/omap_atomic.c 
b/drivers/staging/omapdrm/omap_atomic.c
new file mode 100644
index 000..f078012
--- /dev/null
+++ b/drivers/staging/omapdrm/omap_atomic.c
@@ -0,0 +1,270 @@
+/*
+ * drivers/staging/omapdrm/omap_atomic.c
+ *
+ * Copyright (C) 2012 Texas Instruments
+ * Author: Rob Clark 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+#include "omap_drv.h"
+#include "omap_atomic.h"
+
+struct omap_atomic_state {
+   struct drm_device *dev;
+
+   int num_dirty_planes, num_dirty_crtcs;
+   struct omap_plane_state *plane_state[8];
+   struct omap_crtc_state  *crtc_state[8];
+
+   int num_pending_fbs, num_ready_fbs;
+   struct drm_framebuffer  *pending_fbs[8];
+
+   /* for handling page flips without caring about what
+* the callback is called from.  Possibly we should just
+* make omap_gem always call the cb from the worker so
+* we don't have to care about this..
+*/
+   struct work_struct commit_work;
+};
+
+static void commit_worker(struct work_struct *work);
+
+void *omap_atomic_begin(struct drm_device *dev)
+{
+   struct omap_drm_private *priv = dev->dev_private;
+   struct omap_atomic_state *omap_state;
+
+   // XXX for page_flip, we probably want to know the crtc/crtc_id here,
+   // so we can error out at this point if there is still a pending flip
+   // on this crtc..
+
+   // XXX we should track that we are in-atomic-update per-crtc, so
+   // that page-flips on multple crtc's don't step on each other's feet
+
+   WARN_ON(priv->in_atomic_update);
+   priv->in_atomic_update = true;
+
+   omap_state = kzalloc(sizeof(*omap_state), GFP_KERNEL);
+   if (!omap_state) {
+   dev_err(dev->dev, "failed to allocate state\n");
+   return ERR_PTR(-ENOMEM);
+   }
+
+   omap_state->dev = dev;
+   INIT_WORK(&omap_state->commit_work, commit_worker);
+
+   return omap_state;
+}
+
+int omap_atomic_check(struct drm_device *dev, void *state)
+{
+   struct omap_atomic_state *omap_state = state;
+   struct omap_drm_private *priv = dev->dev_private;
+   int i, ret = 0;
+
+   for (i = 0; (i < ARRAY_SIZE(omap_state->plane_state)) && !ret; i++)
+   if (omap_state->plane_state[i])
+   ret = omap_plane_check_state(priv->planes[i],
+   omap_state->plane_state[i]);
+
+   for (i = 0; (i < ARRAY_SIZE(omap_state->crtc_state)) && !ret; i++)
+   if (omap_state->crtc_state[i])
+   ret = omap_crtc_check_state(priv->crtcs[i],
+   omap_state->crtc_state[i]);
+
+   return ret;
+}
+
+static void commit_worker(struct work_struct *work)
+{
+   struct omap_atomic_state *omap_state =
+   container_of(work, struct omap_atomic_state, 
commit_work);
+   struct drm_device *dev = omap_state->dev;
+   struct omap_drm_private *priv = dev->dev_private;
+   int i;
+
+   mutex_lock(&dev->mode_config.mutex);
+
+   for (i = 0; i < ARRAY_SIZE(omap_state->plane_state); i++)
+   if (omap_state->plane_state[i])
+   omap_plane_commit_state(priv->planes[i],
+   omap_state->plane_state[i]);
+
+   pr

[RFC 0/9] nuclear pageflip

2012-09-09 Thread Rob Clark
On Sun, Sep 9, 2012 at 10:03 PM, Rob Clark  wrote:
> From: Rob Clark 
>
> This is following a bit the approach that Ville is taking for atomic-
> modeset, in that it is switching over to using properties for everything.
> The advantage of this approach is that it makes it easier to add new
> attributes to set as part of a page-flip (and even opens the option to
> add new object types).

oh, and for those wondering what the hell this is all about,
nuclear-pageflip is a pageflip that atomically updates the CRTC layer
and zero or more attached plane layers, optionally changing various
properties such as z-order (or even blending modes, etc) atomically.
It includes the option for a test step so userspace compositor can
test a proposed configuration (if any properties not marked as
'dynamic' are updated).  This intended to allow, for example, weston
compositor to synchronize updates to plane (sprite) layers with CRTC
layer.

BR,
-R

> The basic principles are:
>  a) split out object state (in this case, plane and crtc, although I
> expect more to be added as atomic-modeset is added) into seperate
> structures that can be atomically commited or rolled back
>  b) expand the object property API (set_property()) to take a state
> object.  The obj->set_property() simply updates the state object
> without actually applying the changes to the hw.
>  c) after all the property updates are done, the updated state can
> be checked for correctness and against the hw capabilities, and
> then either discarded or committed atomically.
>
> Since we need to include properties in the nuclear-pageflip scheme,
> doing everything via properties avoids updating a bunch of additional
> driver provided callbacks.  Instead we just drop crtc->page_flip()
> and plane->update_plane().  By splitting out the object's mutable
> state into drm_{plane,crtc,etc}_state structs (which are wrapped by
> the individual drivers to add their own hw specific state), we can
> use some helpers (drm_{plane,crtc,etc}_set_property() and
> drm_{plane,crtc,etc}_check_state()) to keep core error checking in
> drm core and avoid pushing the burden of dealing with common
> properties to the individual drivers.
>
> So far, I've only updated omapdrm to the new APIs, as a proof of
> concept.  Only a few drivers support drm plane, so I expect the
> updates to convert drm-plane to properties should not be so hard.
> Possibly for crtc/pageflip we might need to have a transition period
> where we still support crtc->page_flip() code path until all drivers
> are updated.
>
> My complete branch is here:
>
>   https://github.com/robclark/kernel-omap4/commits/drm_nuclear
>   git://github.com/robclark/kernel-omap4.git drm_nuclear
>
> Rob Clark (9):
>   drm: add atomic fxns
>   drm: add object property type
>   drm: add DRM_MODE_PROP_DYNAMIC property flag
>   drm: convert plane to properties
>   drm: add drm_plane_state
>   drm: convert page_flip to properties
>   drm: add drm_crtc_state
>   drm: nuclear pageflip
>   drm/omap: update for atomic age
>
>  drivers/gpu/drm/drm_crtc.c|  769 
> +++--
>  drivers/gpu/drm/drm_crtc_helper.c |   51 +--
>  drivers/gpu/drm/drm_drv.c |1 +
>  drivers/gpu/drm/drm_fb_helper.c   |   11 +-
>  drivers/staging/omapdrm/Makefile  |1 +
>  drivers/staging/omapdrm/omap_atomic.c |  270 
>  drivers/staging/omapdrm/omap_atomic.h |   52 +++
>  drivers/staging/omapdrm/omap_crtc.c   |  247 +--
>  drivers/staging/omapdrm/omap_drv.c|5 +
>  drivers/staging/omapdrm/omap_drv.h|   35 +-
>  drivers/staging/omapdrm/omap_fb.c |   44 +-
>  drivers/staging/omapdrm/omap_plane.c  |  270 ++--
>  include/drm/drm.h |2 +
>  include/drm/drmP.h|   32 ++
>  include/drm/drm_crtc.h|  140 --
>  include/drm/drm_mode.h|   48 ++
>  16 files changed, 1378 insertions(+), 600 deletions(-)
>  create mode 100644 drivers/staging/omapdrm/omap_atomic.c
>  create mode 100644 drivers/staging/omapdrm/omap_atomic.h
>
> --
> 1.7.9.5
>


3.5-rc7: nouveau doesn't X on NVC0

2012-09-09 Thread Alexey Dobriyan
On Thu, Sep 06, 2012 at 11:33:16AM +1000, Dave Airlie wrote:
> On Thu, Sep 6, 2012 at 11:15 AM, Linus Torvalds
>  wrote:
> > [ This got dropped somehow - it's in my draft folder. The bisection
> > may be irrelevant now: does it work with current git, since we've had
> > some nouveau changes? ]
> >
> > On Tue, Aug 28, 2012 at 8:26 AM, Alexey Dobriyan  
> > wrote:
> >> Ping!
> >>
> >> No X for me with 3.6-rc2.
> 
> Can you try -rc4?
> 
> Ben thinks the pcopy fix should fix it.

I've tried 3.6.0-rc5 and graphics works!


[Bug 42490] NUTMEG DP to VGA bridge not working

2012-09-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=42490

--- Comment #42 from diego.abele...@gmail.com 2012-09-09 07:33:54 UTC ---
I take back what I said before...
I just did a *very* cold boot (the machine was not connected to the electricity
network during the night). I got the black DVI screen and GPU hangup with the
patch. So the firmware change didn't do anything in facts...

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


glapi/libdricore linking trouble with make install targets

2012-09-09 Thread Andreas Radke
When building packages in ArchLinux we try to avoid the old
bin/minstall to move each and every file by hand. So we try to move to
make install targets. Here we run into several linking issues:

  make -C src/glx DESTDIR="${pkgdir}" install

fails with:

make[2]: Entering directory 
`/build/src/mesa-41d14eaf193c6b1eb87fe1998808a887f1c6c698/src/glx'
make[2]: Nothing to be done for `install-data-am'.
 /usr/bin/mkdir -p '/build/pkg/libgl/usr/lib'
 /bin/sh ../../libtool   --mode=install /usr/bin/install -c   libGL.la 
'/build/pkg/libgl/usr/lib'
libtool: install: warning: relinking `libGL.la'
libtool: install: (cd 
/build/src/mesa-41d14eaf193c6b1eb87fe1998808a887f1c6c698/src/glx; /bin/sh 
/build/src/mesa-41d14eaf193c6b1eb87fe1998808a887f1c6c698/libtool  --silent 
--tag CC --mode=relink gcc -I../../include -I../../include/GL/internal 
-I../../src/mapi -I../../src/mapi/glapi -I../../src/mapi -I../../src/mapi/glapi 
-DGLX_SHARED_GLAPI -DXF86VIDMODE -D_REENTRANT 
-DDEFAULT_DRIVER_DIR=\"/usr/lib/xorg/modules/dri\" -D_GNU_SOURCE -DPTHREADS 
-DTEXTURE_FLOAT_ENABLED -DUSE_X86_64_ASM -DHAVE_DLOPEN -DHAVE_POSIX_MEMALIGN 
-DIN_DRI_DRIVER -DUSE_XCB -DGLX_INDIRECT_RENDERING -DGLX_DIRECT_RENDERING 
-DGLX_USE_TLS -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER -DHAVE_ALIAS 
-DHAVE_MINCORE -DHAVE_LIBUDEV -DHAVE_LLVM=0x0301 -I/usr/include/libdrm 
-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector 
--param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -Wall -std=c99 
-Werror=implicit-function-declaration -Werror=missing-prototypes 
-fno-strict-aliasing -fno-builtin-memcmp -Wl,-Bsymbolic -vers
 ion-number 1:2 -no-undefined -Wl,-O1,--sort-common,--as-needed,-z,relro -o 
libGL.la -rpath /usr/lib libglx.la ../../src/mapi/shared-glapi/libglapi.la 
../../src/mapi/glapi/libglapi.la -lXext -lXdamage -lXfixes -lX11-xcb -lX11 
-lxcb-glx -lxcb -lXxf86vm -ldrm -lm -lpthread -ldl -inst-prefix-dir 
/build/pkg/libgl)
/usr/bin/ld: cannot find -lglapi
collect2: error: ld returned 1 exit status
libtool: install: error: relink `libGL.la' with the above command before 
installing it
make[2]: *** [install-libLTLIBRARIES] Error 1


Similar errors happen with other targets. Our community found
a workaround by running this:

  # fix linking because of splitted package
  make -C src/mapi/shared-glapi DESTDIR="${pkgdir}" install

  # libGL & libdricore
  make -C src/glx DESTDIR="${pkgdir}" install
  make -C src/mesa/libdricore DESTDIR="${pkgdir}" install
  
  # fix linking because of splitted package - cleanup
  make -C src/mapi/shared-glapi DESTDIR="${pkgdir}" uninstall



Such step seems to be needed for these other target directories:

* make -C src/egl DESTDIR="${pkgdir}" install
* make -C src/gbm DESTDIR="${pkgdir}" install

Similar issues seem to be there when trying to install the driver targets 
(intel, ati and nouveau),
the workaround seems to be then:

  # fix linking because of splitted package
  make -C src/mesa/libdricore DESTDIR="${pkgdir}" install

  make -C src/mesa/drivers/dri/i915 DESTDIR="${pkgdir}" install
  make -C src/mesa/drivers/dri/i965 DESTDIR="${pkgdir}" install

  # fix linking because of splitted package - cleanup
  make -C src/mesa/libdricore DESTDIR="${pkgdir}" uninstall


Can't these targets do proper linking on their own?

-Andy
ArchLinux
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 43360] nouveau on "NVce" 560 Ti: Failed to idle channel 1

2012-09-09 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=43360





--- Comment #5 from s.je...@gmail.com  2012-09-09 08:08:37 ---
Using Linus' git tree
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git (v3.6-rc4) at

commit eeea3ac912207dcf759b95b2b4c36f96bce583bf
Merge: c7c6bf1 e829c66
Author: Linus Torvalds <*>
Date:   Thu Sep 6 10:23:58 2012 -0700

everything seems to work just fine on my "NVIDIA Corporation GF110 [GeForce GTX
570 HD]". 'dmesg' does not seem to show any warnings or errors and the VT
framebuffer is displayed in a beautifully high resolution. Great work!

-- 
Configure bugmail: https://bugzilla.kernel.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 54129] [bisected] Kernel 3.5.0 breaks KMS on Radeon RV250

2012-09-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=54129

Christian König  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 AssignedTo|dri-devel@lists.freedesktop |deathsim...@vodafone.de
   |.org|

--- Comment #11 from Christian König  2012-09-09 
09:47:55 UTC ---
Created attachment 66876
  --> https://bugs.freedesktop.org/attachment.cgi?id=66876
Possible fix

Please try the attached patch.

Also please supply the output of "sudo cat
/sys/kernel/debug/dri/0/radeon_fence_info" with and without this patch.

Thx,
Christian.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 54675] [RADEON:KMS:RV730XT:HDMI:AUDIO] Screaming audio IRQ with 3.5.3 kernel

2012-09-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=54675

--- Comment #4 from Chris Rankin  2012-09-09 11:21:38 
UTC ---
Apparently, the KMS IRQ can fail even when radeon.audio=0. So it looks like the
audio IRQ always fails and sometimes takes the KMS IRQ with it - seemingly at
random.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 54675] [RADEON:KMS:RV730XT:HDMI:AUDIO] Screaming audio IRQ with 3.5.3 kernel

2012-09-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=54675

--- Comment #5 from Chris Rankin  2012-09-09 13:38:27 
UTC ---
"lspci -n" output for the HD4670:

01:00.0 0300: 1002:9495
01:00.1 0403: 1002:aa38

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 54662] [bisected] Kernel 3.6 breaks KMS on Radeon RV530 (black screen)

2012-09-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=54662

--- Comment #4 from Simon Kitching  2012-09-09 13:43:26 
UTC ---
(In reply to comment #1)
> Can you attach the dmesg output from the non-working case?

Hi Alex,

Thanks very much for your suggestions. 

I'm not sure how to obtain dmesg output, given that I can't get a console in
the failing case. The normal login screen is black, ctrl-alt-f2 doesn't work.
Unfortunately I don't have another machine available to try to SSH to this
laptop. Booting with "nomodeset" works, but then dmesg isn't very useful.

Recent Ubuntu versions don't come with an xorg.conf file, and "sudo Xorg
-configure" reports a fatal error, so I'm not sure how to generate a base file
to tweak.

I could attach /var/log/Xorg.0.log.old after rebooting from the failed state to
something saner, if this would be useful.

However patch "https://bugs.freedesktop.org/attachment.cgi?id=66876"; attached
to bug #54129 appears to fix this bug too, so the above are probably moot.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 54649] Image in Quake 3 is dark

2012-09-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=54649

JS  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||NOTOURBUG

--- Comment #2 from JS  2012-09-09 13:47:43 UTC ---
it is possible

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: glapi/libdricore linking trouble with make install targets

2012-09-09 Thread Laurent Carlier
Le dimanche 9 septembre 2012 09:48:54 Andreas Radke a écrit :
> When building packages in ArchLinux we try to avoid the old
> bin/minstall to move each and every file by hand. So we try to move to
> make install targets. Here we run into several linking issues:
> 
>   make -C src/glx DESTDIR="${pkgdir}" install
> 
> fails with:
> 
> make[2]: Entering directory
> `/build/src/mesa-41d14eaf193c6b1eb87fe1998808a887f1c6c698/src/glx' make[2]:
> Nothing to be done for `install-data-am'.
>  /usr/bin/mkdir -p '/build/pkg/libgl/usr/lib'
>  /bin/sh ../../libtool   --mode=install /usr/bin/install -c   libGL.la
> '/build/pkg/libgl/usr/lib' libtool: install: warning: relinking `libGL.la'
> libtool: install: (cd
> /build/src/mesa-41d14eaf193c6b1eb87fe1998808a887f1c6c698/src/glx; /bin/sh
> /build/src/mesa-41d14eaf193c6b1eb87fe1998808a887f1c6c698/libtool  --silent
> --tag CC --mode=relink gcc -I../../include -I../../include/GL/internal
> -I../../src/mapi -I../../src/mapi/glapi -I../../src/mapi
> -I../../src/mapi/glapi -DGLX_SHARED_GLAPI -DXF86VIDMODE -D_REENTRANT
> -DDEFAULT_DRIVER_DIR=\"/usr/lib/xorg/modules/dri\" -D_GNU_SOURCE -DPTHREADS
> -DTEXTURE_FLOAT_ENABLED -DUSE_X86_64_ASM -DHAVE_DLOPEN
> -DHAVE_POSIX_MEMALIGN -DIN_DRI_DRIVER -DUSE_XCB -DGLX_INDIRECT_RENDERING
> -DGLX_DIRECT_RENDERING -DGLX_USE_TLS -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1
> -DIN_DRI_DRIVER -DHAVE_ALIAS -DHAVE_MINCORE -DHAVE_LIBUDEV
> -DHAVE_LLVM=0x0301 -I/usr/include/libdrm -march=x86-64 -mtune=generic -O2
> -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -Wall
> -std=c99 -Werror=implicit-function-declaration -Werror=missing-prototypes
> -fno-strict-aliasing -fno-builtin-memcmp -Wl,-Bsymbolic -vers ion-number
> 1:2 -no-undefined -Wl,-O1,--sort-common,--as-needed,-z,relro -o libGL.la
> -rpath /usr/lib libglx.la ../../src/mapi/shared-glapi/libglapi.la
> ../../src/mapi/glapi/libglapi.la -lXext -lXdamage -lXfixes -lX11-xcb -lX11
> -lxcb-glx -lxcb -lXxf86vm -ldrm -lm -lpthread -ldl -inst-prefix-dir
> /build/pkg/libgl) /usr/bin/ld: cannot find -lglapi
> collect2: error: ld returned 1 exit status
> libtool: install: error: relink `libGL.la' with the above command before
> installing it make[2]: *** [install-libLTLIBRARIES] Error 1
> 
> 
> Similar errors happen with other targets. Our community found
> a workaround by running this:
> 
>   # fix linking because of splitted package
>   make -C src/mapi/shared-glapi DESTDIR="${pkgdir}" install
> 
>   # libGL & libdricore
>   make -C src/glx DESTDIR="${pkgdir}" install
>   make -C src/mesa/libdricore DESTDIR="${pkgdir}" install
> 
>   # fix linking because of splitted package - cleanup
>   make -C src/mapi/shared-glapi DESTDIR="${pkgdir}" uninstall
> 
> 
> 
> Such step seems to be needed for these other target directories:
> 
> * make -C src/egl DESTDIR="${pkgdir}" install
> * make -C src/gbm DESTDIR="${pkgdir}" install
> 
> Similar issues seem to be there when trying to install the driver targets
> (intel, ati and nouveau), the workaround seems to be then:
> 
>   # fix linking because of splitted package
>   make -C src/mesa/libdricore DESTDIR="${pkgdir}" install
> 
>   make -C src/mesa/drivers/dri/i915 DESTDIR="${pkgdir}" install
>   make -C src/mesa/drivers/dri/i965 DESTDIR="${pkgdir}" install
> 
>   # fix linking because of splitted package - cleanup
>   make -C src/mesa/libdricore DESTDIR="${pkgdir}" uninstall
> 
> 
> Can't these targets do proper linking on their own?
> 
> -Andy
> ArchLinux
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

See https://bugs.freedesktop.org/show_bug.cgi?id=52435

++


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


[Bug 54696] New: unstable frame rate in Quake 3

2012-09-09 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=54696

 Bug #: 54696
   Summary: unstable frame rate in Quake 3
Classification: Unclassified
   Product: Mesa
   Version: git
  Platform: Other
OS/Version: All
Status: NEW
  Severity: major
  Priority: medium
 Component: Drivers/Gallium/i915g
AssignedTo: dri-devel@lists.freedesktop.org
ReportedBy: js314...@gmail.com


average frame rate in demo four is 50 fps, but while playing online game often
reminds slide show - frame rate is between 5 and 60 fps
using classic i915 driver frame rate is more stable, but average is lower

name of display: :0.0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, 
GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer, 
GLX_OML_swap_method, GLX_SGI_swap_control, GLX_SGIS_multisample, 
GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, 
GLX_INTEL_swap_event
client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
client glx extensions:
GLX_ARB_create_context, GLX_ARB_create_context_profile, 
GLX_ARB_create_context_robustness, GLX_ARB_get_proc_address, 
GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_visual_info, 
GLX_EXT_visual_rating, GLX_EXT_framebuffer_sRGB, 
GLX_EXT_create_context_es2_profile, GLX_MESA_copy_sub_buffer, 
GLX_MESA_multithread_makecurrent, GLX_MESA_swap_control, 
GLX_OML_swap_method, GLX_OML_sync_control, GLX_SGI_make_current_read, 
GLX_SGI_swap_control, GLX_SGI_video_sync, GLX_SGIS_multisample, 
GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, 
GLX_EXT_texture_from_pixmap, GLX_INTEL_swap_event
GLX version: 1.4
GLX extensions:
GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_import_context, 
GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer, 
GLX_MESA_multithread_makecurrent, GLX_MESA_swap_control, 
GLX_OML_swap_method, GLX_OML_sync_control, GLX_SGI_make_current_read, 
GLX_SGI_swap_control, GLX_SGI_video_sync, GLX_SGIS_multisample, 
GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, GLX_SGIX_visual_select_group, 
GLX_EXT_texture_from_pixmap
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: Gallium 0.4 on i915 (chipset: G33)
OpenGL version string: 2.1 Mesa 9.0-devel
OpenGL shading language version string: 1.20
OpenGL extensions:
GL_ARB_multisample, GL_EXT_abgr, GL_EXT_bgra, GL_EXT_blend_color, 
GL_EXT_blend_minmax, GL_EXT_blend_subtract, GL_EXT_copy_texture, 
GL_EXT_polygon_offset, GL_EXT_subtexture, GL_EXT_texture_object, 
GL_EXT_vertex_array, GL_EXT_compiled_vertex_array, GL_EXT_texture, 
GL_EXT_texture3D, GL_IBM_rasterpos_clip, GL_ARB_point_parameters, 
GL_EXT_draw_range_elements, GL_EXT_packed_pixels, GL_EXT_point_parameters, 
GL_EXT_rescale_normal, GL_EXT_separate_specular_color, 
GL_EXT_texture_edge_clamp, GL_SGIS_generate_mipmap, 
GL_SGIS_texture_border_clamp, GL_SGIS_texture_edge_clamp, 
GL_SGIS_texture_lod, GL_ARB_multitexture, GL_IBM_multimode_draw_arrays, 
GL_IBM_texture_mirrored_repeat, GL_ARB_texture_cube_map, 
GL_ARB_texture_env_add, GL_ARB_transpose_matrix, 
GL_EXT_blend_func_separate, GL_EXT_fog_coord, GL_EXT_multi_draw_arrays, 
GL_EXT_secondary_color, GL_EXT_texture_env_add, 
GL_EXT_texture_filter_anisotropic, GL_EXT_texture_lod_bias, 
GL_INGR_blend_func_separate, GL_NV_blend_square, GL_NV_light_max_exponent, 
GL_NV_texgen_reflection, GL_NV_texture_env_combine4, 
GL_SUN_multi_draw_arrays, GL_ARB_texture_border_clamp, 
GL_ARB_texture_compression, GL_EXT_framebuffer_object, 
GL_EXT_texture_env_combine, GL_EXT_texture_env_dot3, GL_MESA_window_pos, 
GL_NV_packed_depth_stencil, GL_NV_texture_rectangle, GL_ARB_depth_texture, 
GL_ARB_occlusion_query, GL_ARB_shadow, GL_ARB_texture_env_combine, 
GL_ARB_texture_env_crossbar, GL_ARB_texture_env_dot3, 
GL_ARB_texture_mirrored_repeat, GL_ARB_window_pos, 
GL_EXT_stencil_two_side, GL_EXT_texture_cube_map, GL_NV_fog_distance, 
GL_APPLE_packed_pixels, GL_APPLE_vertex_array_object, GL_ARB_draw_buffers, 
GL_ARB_fragment_program, GL_ARB_fragment_shader, GL_ARB_shader_objects, 
GL_ARB_vertex_program, GL_ARB_vertex_shader, GL_ATI_draw_buffers, 
GL_ATI_texture_env_combine3, GL_EXT_shadow_funcs, GL_EXT_stencil_wrap, 
GL_MESA_pack_invert, GL_MESA_ycbcr_texture, GL_NV_primitive_restart, 
GL_ARB_fragment_program_shadow, GL_ARB_half_float_pixel, 
GL_ARB_occlusion_query2, GL_ARB_point_sprite, GL_ARB_shading_language_100, 
GL_ARB_sync, GL_ARB_texture_non_power_of_two, GL_ARB_vertex_buffer_object, 
GL_ATI_blend_equation_separate, GL_EXT_blend_equation_separate, 
GL_OES_read_format, GL_ARB_pixel_buffer_objec

[RFC] Unified DRM GPU frequency knobs

2012-09-09 Thread Ben Widawsky
On the Intel driver we've developed and reviewed some patches which
enable GPU frequency settings in sysfs. Similar interfaces have existed
for some time in our debugfs, but now we're getting interest from users
like PowerTOP and have decided to formalize it. Most likely other DRM
drivers have similar features; and perhaps similar proposals have gone
out in the past.

Boiling down what we've exposed in our patches:
read current GPU frequency
read/write min frequency
read/write max frequency
read HW support lowest frequency (we call this RPn)
read HW supported highest frequency (we call this RP0)
read HW recommended low frequnecy (we call this RP1)

If no interest is perceived we will move forward with these as Intel
only sysfs interfaces.

The Intel specific patches which are ready to go are here:
http://lists.freedesktop.org/archives/intel-gfx/2012-September/020342.html

Thanks.

-- 
Ben Widawsky, Intel Open Source Technology Center
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [RFC] Unified DRM GPU frequency knobs

2012-09-09 Thread Ben Widawsky
On Sun, 9 Sep 2012 12:42:55 -0700
Ben Widawsky  wrote:

> On the Intel driver we've developed and reviewed some patches which
> enable GPU frequency settings in sysfs. Similar interfaces have
> existed for some time in our debugfs, but now we're getting interest
> from users like PowerTOP and have decided to formalize it. Most
> likely other DRM drivers have similar features; and perhaps similar
> proposals have gone out in the past.
> 
> Boiling down what we've exposed in our patches:
> read current GPU frequency
> read/write min frequency
> read/write max frequency
> read HW support lowest frequency (we call this RPn)
> read HW supported highest frequency (we call this RP0)
> read HW recommended low frequnecy (we call this RP1)
> 
> If no interest is perceived we will move forward with these as Intel
> only sysfs interfaces.
> 
> The Intel specific patches which are ready to go are here:
> http://lists.freedesktop.org/archives/intel-gfx/2012-September/020342.html
> 
> Thanks.
> 

I was called out for not being clear. I'm asking if there
is interest in making unified knobs in DRM as opposed to driver specific
knobs. Is that even a good idea, and/or make sense to do?



-- 
Ben Widawsky, Intel Open Source Technology Center
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: remove property_blob_list

2012-09-09 Thread Rob Clark
On Fri, Sep 7, 2012 at 9:38 PM, Rob Clark  wrote:
> From: Rob Clark 
>
> It isn't used anywhere.

duh, nevermind.. I figured out how it is used.  But maybe I'll add a comment.

BR,
-R

> Signed-off-by: Rob Clark 
> ---
>  drivers/gpu/drm/drm_crtc.c |2 --
>  include/drm/drm_crtc.h |1 -
>  2 files changed, 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 7552675..21a0a85 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -995,7 +995,6 @@ void drm_mode_config_init(struct drm_device *dev)
> INIT_LIST_HEAD(&dev->mode_config.connector_list);
> INIT_LIST_HEAD(&dev->mode_config.encoder_list);
> INIT_LIST_HEAD(&dev->mode_config.property_list);
> -   INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
> INIT_LIST_HEAD(&dev->mode_config.plane_list);
> idr_init(&dev->mode_config.crtc_idr);
>
> @@ -3114,7 +3113,6 @@ static struct drm_property_blob 
> *drm_property_create_blob(struct drm_device *dev
>
> memcpy(blob->data, data, length);
>
> -   list_add_tail(&blob->head, &dev->mode_config.property_blob_list);
> return blob;
>  }
>
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 1422b36..a3574d0d 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -794,7 +794,6 @@ struct drm_mode_config {
> struct delayed_work output_poll_work;
>
> /* pointers to standard properties */
> -   struct list_head property_blob_list;
> struct drm_property *edid_property;
> struct drm_property *dpms_property;
>
> --
> 1.7.9.5
>
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 0/9] nuclear pageflip

2012-09-09 Thread Rob Clark
From: Rob Clark 

This is following a bit the approach that Ville is taking for atomic-
modeset, in that it is switching over to using properties for everything.
The advantage of this approach is that it makes it easier to add new
attributes to set as part of a page-flip (and even opens the option to
add new object types).

The basic principles are:
 a) split out object state (in this case, plane and crtc, although I
expect more to be added as atomic-modeset is added) into seperate
structures that can be atomically commited or rolled back
 b) expand the object property API (set_property()) to take a state
object.  The obj->set_property() simply updates the state object
without actually applying the changes to the hw.
 c) after all the property updates are done, the updated state can
be checked for correctness and against the hw capabilities, and
then either discarded or committed atomically.

Since we need to include properties in the nuclear-pageflip scheme,
doing everything via properties avoids updating a bunch of additional
driver provided callbacks.  Instead we just drop crtc->page_flip()
and plane->update_plane().  By splitting out the object's mutable
state into drm_{plane,crtc,etc}_state structs (which are wrapped by
the individual drivers to add their own hw specific state), we can
use some helpers (drm_{plane,crtc,etc}_set_property() and
drm_{plane,crtc,etc}_check_state()) to keep core error checking in
drm core and avoid pushing the burden of dealing with common
properties to the individual drivers.

So far, I've only updated omapdrm to the new APIs, as a proof of
concept.  Only a few drivers support drm plane, so I expect the
updates to convert drm-plane to properties should not be so hard.
Possibly for crtc/pageflip we might need to have a transition period
where we still support crtc->page_flip() code path until all drivers
are updated.

My complete branch is here:

  https://github.com/robclark/kernel-omap4/commits/drm_nuclear
  git://github.com/robclark/kernel-omap4.git drm_nuclear

Rob Clark (9):
  drm: add atomic fxns
  drm: add object property type
  drm: add DRM_MODE_PROP_DYNAMIC property flag
  drm: convert plane to properties
  drm: add drm_plane_state
  drm: convert page_flip to properties
  drm: add drm_crtc_state
  drm: nuclear pageflip
  drm/omap: update for atomic age

 drivers/gpu/drm/drm_crtc.c|  769 +++--
 drivers/gpu/drm/drm_crtc_helper.c |   51 +--
 drivers/gpu/drm/drm_drv.c |1 +
 drivers/gpu/drm/drm_fb_helper.c   |   11 +-
 drivers/staging/omapdrm/Makefile  |1 +
 drivers/staging/omapdrm/omap_atomic.c |  270 
 drivers/staging/omapdrm/omap_atomic.h |   52 +++
 drivers/staging/omapdrm/omap_crtc.c   |  247 +--
 drivers/staging/omapdrm/omap_drv.c|5 +
 drivers/staging/omapdrm/omap_drv.h|   35 +-
 drivers/staging/omapdrm/omap_fb.c |   44 +-
 drivers/staging/omapdrm/omap_plane.c  |  270 ++--
 include/drm/drm.h |2 +
 include/drm/drmP.h|   32 ++
 include/drm/drm_crtc.h|  140 --
 include/drm/drm_mode.h|   48 ++
 16 files changed, 1378 insertions(+), 600 deletions(-)
 create mode 100644 drivers/staging/omapdrm/omap_atomic.c
 create mode 100644 drivers/staging/omapdrm/omap_atomic.h

-- 
1.7.9.5

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 1/9] drm: add atomic fxns

2012-09-09 Thread Rob Clark
From: Rob Clark 

The 'atomic' mechanism allows for multiple properties to be updated,
checked, and commited atomically.  This will be the basis of atomic-
modeset and nuclear-pageflip.

The basic flow is:

   state = dev->atomic_begin();
   for (... one or more ...)
  obj->set_property(obj, state, prop, value);
   if (dev->atomic_check(state))
  dev->atomic_commit(state, event);
   dev->atomic_end(state);

The split of check and commit steps is to allow for ioctls with a
test-only flag (which would skip the commit step).

The atomic functions are mandatory, as they will end up getting
called from enough places that it is easier not to have to bother
with if-null checks everywhere.

TODO:
  + add some stub atomic functions that can be used by drivers
until they are updated to support atomic operations natively
  + roll-back previous property values if check/commit fails, so
userspace doesn't see incorrect values.
---
 drivers/gpu/drm/drm_crtc.c |  126 +++-
 include/drm/drmP.h |   32 +++
 include/drm/drm_crtc.h |8 +--
 3 files changed, 115 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 7552675..40a3f21 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3227,12 +3227,11 @@ int drm_mode_connector_property_set_ioctl(struct 
drm_device *dev,
return drm_mode_obj_set_property_ioctl(dev, &obj_set_prop, file_priv);
 }
 
-static int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
-  struct drm_property *property,
+static int drm_mode_connector_set_obj_prop(struct drm_connector *connector,
+  void *state, struct drm_property 
*property,
   uint64_t value)
 {
int ret = -EINVAL;
-   struct drm_connector *connector = obj_to_connector(obj);
 
/* Do DPMS ourselves */
if (property == connector->dev->mode_config.dpms_property) {
@@ -3240,7 +3239,7 @@ static int drm_mode_connector_set_obj_prop(struct 
drm_mode_object *obj,
(*connector->funcs->dpms)(connector, (int)value);
ret = 0;
} else if (connector->funcs->set_property)
-   ret = connector->funcs->set_property(connector, property, 
value);
+   ret = connector->funcs->set_property(connector, state, 
property, value);
 
/* store the property value if successful */
if (!ret)
@@ -3248,36 +3247,87 @@ static int drm_mode_connector_set_obj_prop(struct 
drm_mode_object *obj,
return ret;
 }
 
-static int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj,
- struct drm_property *property,
+static int drm_mode_crtc_set_obj_prop(struct drm_crtc *crtc,
+ void *state, struct drm_property 
*property,
  uint64_t value)
 {
int ret = -EINVAL;
-   struct drm_crtc *crtc = obj_to_crtc(obj);
 
if (crtc->funcs->set_property)
-   ret = crtc->funcs->set_property(crtc, property, value);
+   ret = crtc->funcs->set_property(crtc, state, property, value);
if (!ret)
-   drm_object_property_set_value(obj, property, value);
+   drm_object_property_set_value(&crtc->base, property, value);
 
return ret;
 }
 
-static int drm_mode_plane_set_obj_prop(struct drm_mode_object *obj,
- struct drm_property *property,
+static int drm_mode_plane_set_obj_prop(struct drm_plane *plane,
+ void *state, struct drm_property 
*property,
  uint64_t value)
 {
int ret = -EINVAL;
-   struct drm_plane *plane = obj_to_plane(obj);
 
if (plane->funcs->set_property)
-   ret = plane->funcs->set_property(plane, property, value);
+   ret = plane->funcs->set_property(plane, state, property, value);
if (!ret)
-   drm_object_property_set_value(obj, property, value);
+   drm_object_property_set_value(&plane->base, property, value);
 
return ret;
 }
 
+static int drm_mode_set_obj_prop(struct drm_device *dev,
+   struct drm_mode_object *obj, void *state,
+   struct drm_property *property, uint64_t value)
+{
+   if (drm_property_change_is_valid(property, value)) {
+   switch (obj->type) {
+   case DRM_MODE_OBJECT_CONNECTOR:
+   return 
drm_mode_connector_set_obj_prop(obj_to_connector(obj),
+   state, property, value);
+   case DRM_MODE_OBJECT_CRTC:
+   return drm_mode_crtc_set_obj_prop(obj_to_crtc(obj),
+   state, property, value);
+   case DRM_MODE_OBJEC

[RFC 2/9] drm: add object property type

2012-09-09 Thread Rob Clark
From: Rob Clark 

An object property is an id (idr) for a drm mode object.  This
will allow a property to be used set/get a framebuffer, CRTC, etc.
---
 drivers/gpu/drm/drm_crtc.c |   28 
 include/drm/drm_crtc.h |5 +
 include/drm/drm_mode.h |1 +
 3 files changed, 34 insertions(+)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 40a3f21..12829de 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2859,6 +2859,23 @@ struct drm_property *drm_property_create_range(struct 
drm_device *dev, int flags
 }
 EXPORT_SYMBOL(drm_property_create_range);
 
+struct drm_property *drm_property_create_object(struct drm_device *dev,
+int flags, const char *name, uint32_t 
type)
+{
+   struct drm_property *property;
+
+   flags |= DRM_MODE_PROP_OBJECT;
+
+   property = drm_property_create(dev, flags, name, 1);
+   if (!property)
+   return NULL;
+
+   property->values[0] = type;
+
+   return property;
+}
+EXPORT_SYMBOL(drm_property_create_object);
+
 int drm_property_add_enum(struct drm_property *property, int index,
  uint64_t value, const char *name)
 {
@@ -3203,6 +3220,9 @@ static bool drm_property_change_is_valid(struct 
drm_property *property,
for (i = 0; i < property->num_values; i++)
valid_mask |= (1ULL << property->values[i]);
return !(value & ~valid_mask);
+   } else if (property->flags & DRM_MODE_PROP_OBJECT) {
+   /* check for valid object or zero happens elsewhere */
+   return true;
} else {
int i;
for (i = 0; i < property->num_values; i++)
@@ -3280,6 +3300,14 @@ static int drm_mode_set_obj_prop(struct drm_device *dev,
struct drm_property *property, uint64_t value)
 {
if (drm_property_change_is_valid(property, value)) {
+   /* a zero value for an object property translates to null: */
+   if ((property->flags & DRM_MODE_PROP_OBJECT) && value) {
+   struct drm_mode_object *obj =
+   drm_mode_object_find(dev, value, 
property->values[0]);
+   if (!obj)
+   return -EINVAL;
+   value = VOID2U64(obj);
+   }
switch (obj->type) {
case DRM_MODE_OBJECT_CONNECTOR:
return 
drm_mode_connector_set_obj_prop(obj_to_connector(obj),
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index a609190..92df2f4 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -61,6 +61,9 @@ struct drm_object_properties {
uint64_t values[DRM_OBJECT_MAX_PROPERTY];
 };
 
+#define U642VOID(x) ((void *)(unsigned long)(x))
+#define VOID2U64(x) ((uint64_t)(unsigned long)(x))
+
 /*
  * Note on terminology:  here, for brevity and convenience, we refer to 
connector
  * control chips as 'CRTCs'.  They can control any type of connector, VGA, 
LVDS,
@@ -955,6 +958,8 @@ struct drm_property *drm_property_create_bitmask(struct 
drm_device *dev,
 struct drm_property *drm_property_create_range(struct drm_device *dev, int 
flags,
 const char *name,
 uint64_t min, uint64_t max);
+struct drm_property *drm_property_create_object(struct drm_device *dev,
+int flags, const char *name, uint32_t 
type);
 extern void drm_property_destroy(struct drm_device *dev, struct drm_property 
*property);
 extern int drm_property_add_enum(struct drm_property *property, int index,
 uint64_t value, const char *name);
diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
index 5581980..cee4c53 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -231,6 +231,7 @@ struct drm_mode_get_connector {
 #define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */
 #define DRM_MODE_PROP_BLOB (1<<4)
 #define DRM_MODE_PROP_BITMASK  (1<<5) /* bitmask of enumerated types */
+#define DRM_MODE_PROP_OBJECT   (1<<6) /* drm mode object */
 
 struct drm_mode_property_enum {
__u64 value;
-- 
1.7.9.5

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 3/9] drm: add DRM_MODE_PROP_DYNAMIC property flag

2012-09-09 Thread Rob Clark
From: Rob Clark 

This indicates to userspace that the property is something that can
be set dynamically without requiring a "test" step to check if the
hw is capable.  This allows a userspace compositor, such as weston,
to avoid an extra ioctl to check whether it needs to fall-back to
GPU to composite some surface prior to submission of GPU render
commands.
---
 include/drm/drm_mode.h |9 +
 1 file changed, 9 insertions(+)

diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
index cee4c53..8cec2cf 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -232,6 +232,15 @@ struct drm_mode_get_connector {
 #define DRM_MODE_PROP_BLOB (1<<4)
 #define DRM_MODE_PROP_BITMASK  (1<<5) /* bitmask of enumerated types */
 #define DRM_MODE_PROP_OBJECT   (1<<6) /* drm mode object */
+/* Properties that are not dynamic cannot safely be changed without a
+ * atomic-modeset / nuclear-pageflip test step.  But if userspace is
+ * only changing dynamic properties, it is garanteed that the change
+ * will not exceed hw limits, so no test step is required.
+ *
+ * Note that fb_id properties are a bit ambiguous.. they of course can
+ * be changed dynamically, assuming the pixel format does not change.
+ */
+#define DRM_MODE_PROP_DYNAMIC  (1<<24)
 
 struct drm_mode_property_enum {
__u64 value;
-- 
1.7.9.5

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC 4/9] drm: convert plane to properties

2012-09-09 Thread Rob Clark
From: Rob Clark 

Use atomic properties mechanism to set plane attributes.  This by
itself doesn't accomplish anything, but it avoids having multiple
code paths to do the same thing when nuclear-pageflip and atomic-
modeset are introduced.
---
 drivers/gpu/drm/drm_crtc.c |  270 ++--
 include/drm/drm_crtc.h |   32 --
 2 files changed, 187 insertions(+), 115 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 12829de..e680fbe 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -38,6 +38,10 @@
 #include "drm_edid.h"
 #include "drm_fourcc.h"
 
+static int drm_mode_set_obj_prop(struct drm_device *dev,
+   struct drm_mode_object *obj, void *state,
+   struct drm_property *property, uint64_t value);
+
 /* Avoid boilerplate.  I'm tired of typing. */
 #define DRM_ENUM_NAME_FN(fnname, list) \
char *fnname(int val)   \
@@ -380,11 +384,19 @@ EXPORT_SYMBOL(drm_framebuffer_cleanup);
 void drm_framebuffer_remove(struct drm_framebuffer *fb)
 {
struct drm_device *dev = fb->dev;
+   struct drm_mode_config *config = &dev->mode_config;
struct drm_crtc *crtc;
struct drm_plane *plane;
struct drm_mode_set set;
+   void *state;
int ret;
 
+   state = dev->driver->atomic_begin(dev);
+   if (IS_ERR(state)) {
+   DRM_ERROR("failed to disable crtc and/or plane when fb was 
deleted\n");
+   return;
+   }
+
/* remove from any CRTC */
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
if (crtc->fb == fb) {
@@ -401,15 +413,19 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
list_for_each_entry(plane, &dev->mode_config.plane_list, head) {
if (plane->fb == fb) {
/* should turn off the crtc */
-   ret = plane->funcs->disable_plane(plane);
-   if (ret)
-   DRM_ERROR("failed to disable plane with busy 
fb\n");
-   /* disconnect the plane from the fb and crtc: */
-   plane->fb = NULL;
-   plane->crtc = NULL;
+   drm_mode_plane_set_obj_prop(plane, state, 
config->prop_crtc_id, 0);
+   drm_mode_plane_set_obj_prop(plane, state, 
config->prop_fb_id, 0);
}
}
 
+   /* just disabling stuff shouldn't fail, hopefully: */
+   if(dev->driver->atomic_check(dev, state))
+   DRM_ERROR("failed to disable crtc and/or plane when fb was 
deleted\n");
+   else
+   dev->driver->atomic_commit(dev, state, NULL);
+
+   dev->driver->atomic_end(dev, state);
+
list_del(&fb->filp_head);
 
drm_framebuffer_unreference(fb);
@@ -661,6 +677,7 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane 
*plane,
   const uint32_t *formats, uint32_t format_count,
   bool priv)
 {
+   struct drm_mode_config *config = &dev->mode_config;
int ret;
 
mutex_lock(&dev->mode_config.mutex);
@@ -696,6 +713,17 @@ int drm_plane_init(struct drm_device *dev, struct 
drm_plane *plane,
INIT_LIST_HEAD(&plane->head);
}
 
+   drm_object_attach_property(&plane->base, config->prop_fb_id, 0);
+   drm_object_attach_property(&plane->base, config->prop_crtc_id, 0);
+   drm_object_attach_property(&plane->base, config->prop_crtc_x, 0);
+   drm_object_attach_property(&plane->base, config->prop_crtc_y, 0);
+   drm_object_attach_property(&plane->base, config->prop_crtc_w, 0);
+   drm_object_attach_property(&plane->base, config->prop_crtc_h, 0);
+   drm_object_attach_property(&plane->base, config->prop_src_x, 0);
+   drm_object_attach_property(&plane->base, config->prop_src_y, 0);
+   drm_object_attach_property(&plane->base, config->prop_src_w, 0);
+   drm_object_attach_property(&plane->base, config->prop_src_h, 0);
+
  out:
mutex_unlock(&dev->mode_config.mutex);
 
@@ -769,23 +797,89 @@ void drm_mode_destroy(struct drm_device *dev, struct 
drm_display_mode *mode)
 }
 EXPORT_SYMBOL(drm_mode_destroy);
 
-static int drm_mode_create_standard_connector_properties(struct drm_device 
*dev)
+static int drm_mode_create_standard_properties(struct drm_device *dev)
 {
-   struct drm_property *edid;
-   struct drm_property *dpms;
+   struct drm_property *prop;
 
/*
 * Standard properties (apply to all connectors)
 */
-   edid = drm_property_create(dev, DRM_MODE_PROP_BLOB |
+   prop = drm_property_create(dev, DRM_MODE_PROP_BLOB |
   DRM_MODE_PROP_IMMUTABLE,
   "EDID", 0);
-   dev->mode_config.edid_property = edid;
+   if (!prop)
+   return -ENOMEM;
+   

[RFC 5/9] drm: add drm_plane_state

2012-09-09 Thread Rob Clark
From: Rob Clark 

Break the mutable state of a plane out into a separate structure.
This makes it easier to have some helpers for plane->set_property()
and for checking for invalid params.  The idea is that individual
drivers can wrap the state struct in their own struct which adds
driver specific parameters, for easy build-up of state across
multiple set_property() calls and for easy atomic commit or roll-
back.

The same should be done for CRTC, encoder, and connector, but this
patch only includes the first part (plane).
---
 drivers/gpu/drm/drm_crtc.c |   97 +---
 include/drm/drm_crtc.h |   38 +
 2 files changed, 123 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index e680fbe..ce6fa6a 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -411,7 +411,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
}
 
list_for_each_entry(plane, &dev->mode_config.plane_list, head) {
-   if (plane->fb == fb) {
+   if (plane->state->fb == fb) {
/* should turn off the crtc */
drm_mode_plane_set_obj_prop(plane, state, 
config->prop_crtc_id, 0);
drm_mode_plane_set_obj_prop(plane, state, 
config->prop_fb_id, 0);
@@ -747,6 +747,93 @@ void drm_plane_cleanup(struct drm_plane *plane)
 }
 EXPORT_SYMBOL(drm_plane_cleanup);
 
+int drm_plane_check_state(struct drm_plane *plane,
+   struct drm_plane_state *state)
+{
+   unsigned int fb_width, fb_height;
+   struct drm_framebuffer *fb = state->fb;
+   int i;
+
+   fb_width = fb->width << 16;
+   fb_height = fb->height << 16;
+
+   /* Check whether this plane supports the fb pixel format. */
+   for (i = 0; i < plane->format_count; i++)
+   if (fb->pixel_format == plane->format_types[i])
+   break;
+   if (i == plane->format_count) {
+   DRM_DEBUG_KMS("Invalid pixel format 0x%08x\n", 
fb->pixel_format);
+   return -EINVAL;
+   }
+
+   /* Make sure source coordinates are inside the fb. */
+   if (state->src_w > fb_width ||
+   state->src_x > fb_width - state->src_w ||
+   state->src_h > fb_height ||
+   state->src_y > fb_height - state->src_h) {
+   DRM_DEBUG_KMS("Invalid source coordinates "
+ "%u.%06ux%u.%06u+%u.%06u+%u.%06u\n",
+ state->src_w >> 16,
+ ((state->src_w & 0x) * 15625) >> 10,
+ state->src_h >> 16,
+ ((state->src_h & 0x) * 15625) >> 10,
+ state->src_x >> 16,
+ ((state->src_x & 0x) * 15625) >> 10,
+ state->src_y >> 16,
+ ((state->src_y & 0x) * 15625) >> 10);
+   return -ENOSPC;
+   }
+
+   /* Give drivers some help against integer overflows */
+   if (state->crtc_w > INT_MAX ||
+   state->crtc_x > INT_MAX - (int32_t) state->crtc_w ||
+   state->crtc_h > INT_MAX ||
+   state->crtc_y > INT_MAX - (int32_t) state->crtc_h) {
+   DRM_DEBUG_KMS("Invalid CRTC coordinates %ux%u+%d+%d\n",
+ state->crtc_w, state->crtc_h,
+ state->crtc_x, state->crtc_y);
+   return -ERANGE;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_plane_check_state);
+
+int drm_plane_set_property(struct drm_plane *plane,
+   struct drm_plane_state *state,
+   struct drm_property *property, uint64_t value)
+{
+   struct drm_device *dev = plane->dev;
+   struct drm_mode_config *config = &dev->mode_config;
+
+   if (property == config->prop_fb_id) {
+   state->fb = U642VOID(value);
+   } else if (property == config->prop_crtc_id) {
+   state->crtc = U642VOID(value);
+   } else if (property == config->prop_crtc_x) {
+   state->crtc_x = *(int32_t *)&value;
+   } else if (property == config->prop_crtc_y) {
+   state->crtc_y = *(int32_t *)&value;
+   } else if (property == config->prop_crtc_w) {
+   state->crtc_w = value;
+   } else if (property == config->prop_crtc_h) {
+   state->crtc_h = value;
+   } else if (property == config->prop_src_x) {
+   state->src_x = value;
+   } else if (property == config->prop_src_y) {
+   state->src_y = value;
+   } else if (property == config->prop_src_w) {
+   state->src_w = value;
+   } else if (property == config->prop_src_h) {
+   state->src_h = value;
+   } else {
+   return -EINVAL;
+   }
+
+   return 0;

[RFC 6/9] drm: convert page_flip to properties

2012-09-09 Thread Rob Clark
From: Rob Clark 

Use atomic properties mechanism for CRTC page_flip.  This by itself
doesn't accomplish anything, but it avoids having multiple code
paths to do the same thing when nuclear-pageflip and atomic-modeset
are introduced.
---
 drivers/gpu/drm/drm_crtc.c |   59 +---
 include/drm/drm_crtc.h |   13 --
 2 files changed, 23 insertions(+), 49 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index ce6fa6a..8be57e4 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -387,9 +387,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
struct drm_mode_config *config = &dev->mode_config;
struct drm_crtc *crtc;
struct drm_plane *plane;
-   struct drm_mode_set set;
void *state;
-   int ret;
 
state = dev->driver->atomic_begin(dev);
if (IS_ERR(state)) {
@@ -401,12 +399,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
if (crtc->fb == fb) {
/* should turn off the crtc */
-   memset(&set, 0, sizeof(struct drm_mode_set));
-   set.crtc = crtc;
-   set.fb = NULL;
-   ret = crtc->funcs->set_config(&set);
-   if (ret)
-   DRM_ERROR("failed to reset crtc %p when fb was 
deleted\n", crtc);
+   drm_mode_crtc_set_obj_prop(crtc, state, 
config->prop_crtc_id, 0);
}
}
 
@@ -449,6 +442,7 @@ EXPORT_SYMBOL(drm_framebuffer_remove);
 int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
   const struct drm_crtc_funcs *funcs)
 {
+   struct drm_mode_config *config = &dev->mode_config;
int ret;
 
crtc->dev = dev;
@@ -466,6 +460,10 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc 
*crtc,
list_add_tail(&crtc->head, &dev->mode_config.crtc_list);
dev->mode_config.num_crtc++;
 
+   drm_object_attach_property(&crtc->base, config->prop_fb_id, 0);
+   drm_object_attach_property(&crtc->base, config->prop_crtc_x, 0);
+   drm_object_attach_property(&crtc->base, config->prop_crtc_y, 0);
+
  out:
mutex_unlock(&dev->mode_config.mutex);
 
@@ -3750,12 +3748,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 void *data, struct drm_file *file_priv)
 {
struct drm_mode_crtc_page_flip *page_flip = data;
+   struct drm_mode_config *config = &dev->mode_config;
struct drm_mode_object *obj;
struct drm_crtc *crtc;
-   struct drm_framebuffer *fb;
struct drm_pending_vblank_event *e = NULL;
unsigned long flags;
-   int hdisplay, vdisplay;
+   void *state;
int ret = -EINVAL;
 
if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS ||
@@ -3763,6 +3761,13 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
return -EINVAL;
 
mutex_lock(&dev->mode_config.mutex);
+
+   state = dev->driver->atomic_begin(dev);
+   if (IS_ERR(state)) {
+   ret = PTR_ERR(state);
+   goto out_unlock;
+   }
+
obj = drm_mode_object_find(dev, page_flip->crtc_id, 
DRM_MODE_OBJECT_CRTC);
if (!obj)
goto out;
@@ -3777,31 +3782,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
goto out;
}
 
-   if (crtc->funcs->page_flip == NULL)
-   goto out;
-
-   obj = drm_mode_object_find(dev, page_flip->fb_id, DRM_MODE_OBJECT_FB);
-   if (!obj)
-   goto out;
-   fb = obj_to_fb(obj);
-
-   hdisplay = crtc->mode.hdisplay;
-   vdisplay = crtc->mode.vdisplay;
-
-   if (crtc->invert_dimensions)
-   swap(hdisplay, vdisplay);
-
-   if (hdisplay > fb->width ||
-   vdisplay > fb->height ||
-   crtc->x > fb->width - hdisplay ||
-   crtc->y > fb->height - vdisplay) {
-   DRM_DEBUG_KMS("Invalid fb size %ux%u for CRTC viewport 
%ux%u+%d+%d%s.\n",
- fb->width, fb->height, hdisplay, vdisplay, 
crtc->x, crtc->y,
- crtc->invert_dimensions ? " (inverted)" : "");
-   ret = -ENOSPC;
-   goto out;
-   }
-
if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
ret = -ENOMEM;
spin_lock_irqsave(&dev->event_lock, flags);
@@ -3829,7 +3809,12 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
(void (*) (struct drm_pending_event *)) kfree;
}
 
-   ret = crtc->funcs->page_flip(crtc, fb, e);
+   ret = drm_mode_set_obj_prop(dev, obj, state,
+   config->prop_fb_id, page_flip->fb_id);
+   if (ret)
+   goto out;
+
+   ret = dev->driver->atomic_commit(dev, state

[RFC 7/9] drm: add drm_crtc_state

2012-09-09 Thread Rob Clark
From: Rob Clark 

Start breaking out the mutable state of the CRTC into it's own
structure.  Plus add _check_state() and _set_property() helpers.
This only moves the state that is related to scanout fb, which
is needed for nuclear-pageflip.  The rest of the mutable state
should be moved from drm_crtc to drm_crtc_state as part of the
atomic-modeset implementation.
---
 drivers/gpu/drm/drm_crtc.c|   70 +++--
 drivers/gpu/drm/drm_crtc_helper.c |   51 ++-
 drivers/gpu/drm/drm_fb_helper.c   |   11 +++---
 include/drm/drm_crtc.h|   44 +--
 4 files changed, 125 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 8be57e4..0ddd43e 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -397,7 +397,7 @@ void drm_framebuffer_remove(struct drm_framebuffer *fb)
 
/* remove from any CRTC */
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
-   if (crtc->fb == fb) {
+   if (crtc->state->fb == fb) {
/* should turn off the crtc */
drm_mode_crtc_set_obj_prop(crtc, state, 
config->prop_crtc_id, 0);
}
@@ -447,7 +447,7 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc 
*crtc,
 
crtc->dev = dev;
crtc->funcs = funcs;
-   crtc->invert_dimensions = false;
+   crtc->state->invert_dimensions = false;
 
mutex_lock(&dev->mode_config.mutex);
 
@@ -496,6 +496,54 @@ void drm_crtc_cleanup(struct drm_crtc *crtc)
 }
 EXPORT_SYMBOL(drm_crtc_cleanup);
 
+int drm_crtc_check_state(struct drm_crtc *crtc,
+   struct drm_crtc_state *state)
+{
+   struct drm_framebuffer *fb = state->fb;
+   int hdisplay, vdisplay;
+
+   hdisplay = crtc->mode.hdisplay;
+   vdisplay = crtc->mode.vdisplay;
+
+   if (state->invert_dimensions)
+   swap(hdisplay, vdisplay);
+
+   if (hdisplay > fb->width ||
+   vdisplay > fb->height ||
+   state->x > fb->width - hdisplay ||
+   state->y > fb->height - vdisplay) {
+   DRM_DEBUG_KMS("Invalid fb size %ux%u for CRTC viewport 
%ux%u+%d+%d%s.\n",
+ fb->width, fb->height, hdisplay, vdisplay,
+ state->x, state->y,
+ state->invert_dimensions ? " (inverted)" : "");
+   return -ENOSPC;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_crtc_check_state);
+
+int drm_crtc_set_property(struct drm_crtc *crtc,
+   struct drm_crtc_state *state,
+   struct drm_property *property, uint64_t value)
+{
+   struct drm_device *dev = crtc->dev;
+   struct drm_mode_config *config = &dev->mode_config;
+
+   if (property == config->prop_fb_id) {
+   state->fb = U642VOID(value);
+   } else if (property == config->prop_crtc_x) {
+   state->x = *(int *)&value;
+   } else if (property == config->prop_crtc_y) {
+   state->y = *(int32_t *)&value;
+   } else {
+   return -EINVAL;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(drm_crtc_set_property);
+
 /**
  * drm_mode_probed_add - add a mode to a connector's probed mode list
  * @connector: connector the new mode
@@ -1593,11 +1641,11 @@ int drm_mode_getcrtc(struct drm_device *dev,
}
crtc = obj_to_crtc(obj);
 
-   crtc_resp->x = crtc->x;
-   crtc_resp->y = crtc->y;
+   crtc_resp->x = crtc->state->x;
+   crtc_resp->y = crtc->state->y;
crtc_resp->gamma_size = crtc->gamma_size;
-   if (crtc->fb)
-   crtc_resp->fb_id = crtc->fb->base.id;
+   if (crtc->state->fb)
+   crtc_resp->fb_id = crtc->state->fb->base.id;
else
crtc_resp->fb_id = 0;
 
@@ -2042,12 +2090,12 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
/* If we have a mode we need a framebuffer. */
/* If we pass -1, set the mode with the currently bound fb */
if (crtc_req->fb_id == -1) {
-   if (!crtc->fb) {
+   if (!crtc->state->fb) {
DRM_DEBUG_KMS("CRTC doesn't have current FB\n");
ret = -EINVAL;
goto out;
}
-   fb = crtc->fb;
+   fb = crtc->state->fb;
} else {
obj = drm_mode_object_find(dev, crtc_req->fb_id,
   DRM_MODE_OBJECT_FB);
@@ -2077,7 +2125,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
hdisplay = mode->hdisplay;
vdisplay = mode->vdisplay;
 
-   if (crtc->invert_dimensions)
+   if (crtc->state->invert_dimensions)
swap(

[RFC 8/9] drm: nuclear pageflip

2012-09-09 Thread Rob Clark
From: Rob Clark 

---
 drivers/gpu/drm/drm_crtc.c |  147 +++-
 drivers/gpu/drm/drm_drv.c  |1 +
 include/drm/drm.h  |2 +
 include/drm/drm_crtc.h |2 +
 include/drm/drm_mode.h |   38 
 5 files changed, 161 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 0ddd43e..d285b11 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -3792,6 +3792,51 @@ out:
return ret;
 }
 
+static struct drm_pending_vblank_event *create_vblank_event(
+   struct drm_device *dev, struct drm_file *file_priv, uint64_t 
user_data)
+{
+   struct drm_pending_vblank_event *e = NULL;
+   unsigned long flags;
+
+   spin_lock_irqsave(&dev->event_lock, flags);
+   if (file_priv->event_space < sizeof e->event) {
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+   goto out;
+   }
+   file_priv->event_space -= sizeof e->event;
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+
+   e = kzalloc(sizeof *e, GFP_KERNEL);
+   if (e == NULL) {
+   spin_lock_irqsave(&dev->event_lock, flags);
+   file_priv->event_space += sizeof e->event;
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+   goto out;
+   }
+
+   e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
+   e->event.base.length = sizeof e->event;
+   e->event.user_data = user_data;
+   e->base.event = &e->event.base;
+   e->base.file_priv = file_priv;
+   e->base.destroy =
+   (void (*) (struct drm_pending_event *)) kfree;
+
+out:
+   return e;
+}
+
+static void destroy_vblank_event(struct drm_device *dev,
+   struct drm_file *file_priv, struct drm_pending_vblank_event *e)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(&dev->event_lock, flags);
+   file_priv->event_space += sizeof e->event;
+   spin_unlock_irqrestore(&dev->event_lock, flags);
+   kfree(e);
+}
+
 int drm_mode_page_flip_ioctl(struct drm_device *dev,
 void *data, struct drm_file *file_priv)
 {
@@ -3800,7 +3845,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
struct drm_mode_object *obj;
struct drm_crtc *crtc;
struct drm_pending_vblank_event *e = NULL;
-   unsigned long flags;
void *state;
int ret = -EINVAL;
 
@@ -3831,30 +3875,11 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
}
 
if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
-   ret = -ENOMEM;
-   spin_lock_irqsave(&dev->event_lock, flags);
-   if (file_priv->event_space < sizeof e->event) {
-   spin_unlock_irqrestore(&dev->event_lock, flags);
-   goto out;
-   }
-   file_priv->event_space -= sizeof e->event;
-   spin_unlock_irqrestore(&dev->event_lock, flags);
-
-   e = kzalloc(sizeof *e, GFP_KERNEL);
-   if (e == NULL) {
-   spin_lock_irqsave(&dev->event_lock, flags);
-   file_priv->event_space += sizeof e->event;
-   spin_unlock_irqrestore(&dev->event_lock, flags);
+   e = create_vblank_event(dev, file_priv, page_flip->user_data);
+   if (!e) {
+   ret = -ENOMEM;
goto out;
}
-
-   e->event.base.type = DRM_EVENT_FLIP_COMPLETE;
-   e->event.base.length = sizeof e->event;
-   e->event.user_data = page_flip->user_data;
-   e->base.event = &e->event.base;
-   e->base.file_priv = file_priv;
-   e->base.destroy =
-   (void (*) (struct drm_pending_event *)) kfree;
}
 
ret = drm_mode_set_obj_prop(dev, obj, state,
@@ -3863,15 +3888,79 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
goto out;
 
ret = dev->driver->atomic_commit(dev, state, e);
-   if (ret) {
-   if (page_flip->flags & DRM_MODE_PAGE_FLIP_EVENT) {
-   spin_lock_irqsave(&dev->event_lock, flags);
-   file_priv->event_space += sizeof e->event;
-   spin_unlock_irqrestore(&dev->event_lock, flags);
-   kfree(e);
+   if (ret && e)
+   destroy_vblank_event(dev, file_priv, e);
+
+out:
+   dev->driver->atomic_end(dev, state);
+out_unlock:
+   mutex_unlock(&dev->mode_config.mutex);
+   return ret;
+}
+
+int drm_mode_nuclear_page_flip_ioctl(struct drm_device *dev,
+void *data, struct drm_file *file_priv)
+{
+   struct drm_mode_crtc_nuclear_page_flip *page_flip = data;
+   struct drm_mode_obj_set_property __user *props =
+   (struct drm_mode_obj_set_property __user *)
+ 

[RFC 9/9] drm/omap: update for atomic age

2012-09-09 Thread Rob Clark
From: Rob Clark 

---
 drivers/staging/omapdrm/Makefile  |1 +
 drivers/staging/omapdrm/omap_atomic.c |  270 +
 drivers/staging/omapdrm/omap_atomic.h |   52 +++
 drivers/staging/omapdrm/omap_crtc.c   |  247 +-
 drivers/staging/omapdrm/omap_drv.c|5 +
 drivers/staging/omapdrm/omap_drv.h|   35 +++--
 drivers/staging/omapdrm/omap_fb.c |   44 +++---
 drivers/staging/omapdrm/omap_plane.c  |  270 +
 8 files changed, 616 insertions(+), 308 deletions(-)
 create mode 100644 drivers/staging/omapdrm/omap_atomic.c
 create mode 100644 drivers/staging/omapdrm/omap_atomic.h

diff --git a/drivers/staging/omapdrm/Makefile b/drivers/staging/omapdrm/Makefile
index d85e058..7d45e4d 100644
--- a/drivers/staging/omapdrm/Makefile
+++ b/drivers/staging/omapdrm/Makefile
@@ -13,6 +13,7 @@ omapdrm-y := omap_drv.o \
omap_connector.o \
omap_fb.o \
omap_fbdev.o \
+   omap_atomic.o \
omap_gem.o \
omap_gem_dmabuf.o \
omap_dmm_tiler.o \
diff --git a/drivers/staging/omapdrm/omap_atomic.c 
b/drivers/staging/omapdrm/omap_atomic.c
new file mode 100644
index 000..f078012
--- /dev/null
+++ b/drivers/staging/omapdrm/omap_atomic.c
@@ -0,0 +1,270 @@
+/*
+ * drivers/staging/omapdrm/omap_atomic.c
+ *
+ * Copyright (C) 2012 Texas Instruments
+ * Author: Rob Clark 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+#include "omap_drv.h"
+#include "omap_atomic.h"
+
+struct omap_atomic_state {
+   struct drm_device *dev;
+
+   int num_dirty_planes, num_dirty_crtcs;
+   struct omap_plane_state *plane_state[8];
+   struct omap_crtc_state  *crtc_state[8];
+
+   int num_pending_fbs, num_ready_fbs;
+   struct drm_framebuffer  *pending_fbs[8];
+
+   /* for handling page flips without caring about what
+* the callback is called from.  Possibly we should just
+* make omap_gem always call the cb from the worker so
+* we don't have to care about this..
+*/
+   struct work_struct commit_work;
+};
+
+static void commit_worker(struct work_struct *work);
+
+void *omap_atomic_begin(struct drm_device *dev)
+{
+   struct omap_drm_private *priv = dev->dev_private;
+   struct omap_atomic_state *omap_state;
+
+   // XXX for page_flip, we probably want to know the crtc/crtc_id here,
+   // so we can error out at this point if there is still a pending flip
+   // on this crtc..
+
+   // XXX we should track that we are in-atomic-update per-crtc, so
+   // that page-flips on multple crtc's don't step on each other's feet
+
+   WARN_ON(priv->in_atomic_update);
+   priv->in_atomic_update = true;
+
+   omap_state = kzalloc(sizeof(*omap_state), GFP_KERNEL);
+   if (!omap_state) {
+   dev_err(dev->dev, "failed to allocate state\n");
+   return ERR_PTR(-ENOMEM);
+   }
+
+   omap_state->dev = dev;
+   INIT_WORK(&omap_state->commit_work, commit_worker);
+
+   return omap_state;
+}
+
+int omap_atomic_check(struct drm_device *dev, void *state)
+{
+   struct omap_atomic_state *omap_state = state;
+   struct omap_drm_private *priv = dev->dev_private;
+   int i, ret = 0;
+
+   for (i = 0; (i < ARRAY_SIZE(omap_state->plane_state)) && !ret; i++)
+   if (omap_state->plane_state[i])
+   ret = omap_plane_check_state(priv->planes[i],
+   omap_state->plane_state[i]);
+
+   for (i = 0; (i < ARRAY_SIZE(omap_state->crtc_state)) && !ret; i++)
+   if (omap_state->crtc_state[i])
+   ret = omap_crtc_check_state(priv->crtcs[i],
+   omap_state->crtc_state[i]);
+
+   return ret;
+}
+
+static void commit_worker(struct work_struct *work)
+{
+   struct omap_atomic_state *omap_state =
+   container_of(work, struct omap_atomic_state, 
commit_work);
+   struct drm_device *dev = omap_state->dev;
+   struct omap_drm_private *priv = dev->dev_private;
+   int i;
+
+   mutex_lock(&dev->mode_config.mutex);
+
+   for (i = 0; i < ARRAY_SIZE(omap_state->plane_state); i++)
+   if (omap_state->plane_state[i])
+   omap_plane_commit_state(priv->planes[i],
+   omap_state->plane_state[i]);
+
+   pr

Re: [RFC 0/9] nuclear pageflip

2012-09-09 Thread Rob Clark
On Sun, Sep 9, 2012 at 10:03 PM, Rob Clark  wrote:
> From: Rob Clark 
>
> This is following a bit the approach that Ville is taking for atomic-
> modeset, in that it is switching over to using properties for everything.
> The advantage of this approach is that it makes it easier to add new
> attributes to set as part of a page-flip (and even opens the option to
> add new object types).

oh, and for those wondering what the hell this is all about,
nuclear-pageflip is a pageflip that atomically updates the CRTC layer
and zero or more attached plane layers, optionally changing various
properties such as z-order (or even blending modes, etc) atomically.
It includes the option for a test step so userspace compositor can
test a proposed configuration (if any properties not marked as
'dynamic' are updated).  This intended to allow, for example, weston
compositor to synchronize updates to plane (sprite) layers with CRTC
layer.

BR,
-R

> The basic principles are:
>  a) split out object state (in this case, plane and crtc, although I
> expect more to be added as atomic-modeset is added) into seperate
> structures that can be atomically commited or rolled back
>  b) expand the object property API (set_property()) to take a state
> object.  The obj->set_property() simply updates the state object
> without actually applying the changes to the hw.
>  c) after all the property updates are done, the updated state can
> be checked for correctness and against the hw capabilities, and
> then either discarded or committed atomically.
>
> Since we need to include properties in the nuclear-pageflip scheme,
> doing everything via properties avoids updating a bunch of additional
> driver provided callbacks.  Instead we just drop crtc->page_flip()
> and plane->update_plane().  By splitting out the object's mutable
> state into drm_{plane,crtc,etc}_state structs (which are wrapped by
> the individual drivers to add their own hw specific state), we can
> use some helpers (drm_{plane,crtc,etc}_set_property() and
> drm_{plane,crtc,etc}_check_state()) to keep core error checking in
> drm core and avoid pushing the burden of dealing with common
> properties to the individual drivers.
>
> So far, I've only updated omapdrm to the new APIs, as a proof of
> concept.  Only a few drivers support drm plane, so I expect the
> updates to convert drm-plane to properties should not be so hard.
> Possibly for crtc/pageflip we might need to have a transition period
> where we still support crtc->page_flip() code path until all drivers
> are updated.
>
> My complete branch is here:
>
>   https://github.com/robclark/kernel-omap4/commits/drm_nuclear
>   git://github.com/robclark/kernel-omap4.git drm_nuclear
>
> Rob Clark (9):
>   drm: add atomic fxns
>   drm: add object property type
>   drm: add DRM_MODE_PROP_DYNAMIC property flag
>   drm: convert plane to properties
>   drm: add drm_plane_state
>   drm: convert page_flip to properties
>   drm: add drm_crtc_state
>   drm: nuclear pageflip
>   drm/omap: update for atomic age
>
>  drivers/gpu/drm/drm_crtc.c|  769 
> +++--
>  drivers/gpu/drm/drm_crtc_helper.c |   51 +--
>  drivers/gpu/drm/drm_drv.c |1 +
>  drivers/gpu/drm/drm_fb_helper.c   |   11 +-
>  drivers/staging/omapdrm/Makefile  |1 +
>  drivers/staging/omapdrm/omap_atomic.c |  270 
>  drivers/staging/omapdrm/omap_atomic.h |   52 +++
>  drivers/staging/omapdrm/omap_crtc.c   |  247 +--
>  drivers/staging/omapdrm/omap_drv.c|5 +
>  drivers/staging/omapdrm/omap_drv.h|   35 +-
>  drivers/staging/omapdrm/omap_fb.c |   44 +-
>  drivers/staging/omapdrm/omap_plane.c  |  270 ++--
>  include/drm/drm.h |2 +
>  include/drm/drmP.h|   32 ++
>  include/drm/drm_crtc.h|  140 --
>  include/drm/drm_mode.h|   48 ++
>  16 files changed, 1378 insertions(+), 600 deletions(-)
>  create mode 100644 drivers/staging/omapdrm/omap_atomic.c
>  create mode 100644 drivers/staging/omapdrm/omap_atomic.h
>
> --
> 1.7.9.5
>
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/5] gpu/vga_switcheroo: add driver control power feature.

2012-09-09 Thread Dave Airlie
From: Dave Airlie 

For optimus and powerxpress muxless we really want the GPU
driver deciding when to power up/down the GPU, not userspace.

This adds the ability for a driver to dynamically power up/down
the GPU and remove the switcheroo from controlling it, the
switcheroo reports the dynamic state to userspace also.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/i915/i915_dma.c|  2 +-
 drivers/gpu/drm/nouveau/nouveau_vga.c  |  2 +-
 drivers/gpu/drm/radeon/radeon_device.c |  2 +-
 drivers/gpu/vga/vga_switcheroo.c   | 44 ++
 include/linux/vga_switcheroo.h |  6 -
 5 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 9cf7dfe..a377204 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1302,7 +1302,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
 
intel_register_dsm_handler();
 
-   ret = vga_switcheroo_register_client(dev->pdev, &i915_switcheroo_ops);
+   ret = vga_switcheroo_register_client(dev->pdev, &i915_switcheroo_ops, 
false);
if (ret)
goto cleanup_vga_client;
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c 
b/drivers/gpu/drm/nouveau/nouveau_vga.c
index 7bf7d13..37fcc9d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -80,7 +80,7 @@ nouveau_vga_init(struct nouveau_drm *drm)
 {
struct drm_device *dev = drm->dev;
vga_client_register(dev->pdev, dev, NULL, nouveau_vga_set_decode);
-   vga_switcheroo_register_client(dev->pdev, &nouveau_switcheroo_ops);
+   vga_switcheroo_register_client(dev->pdev, &nouveau_switcheroo_ops, 
false);
 }
 
 void
diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
b/drivers/gpu/drm/radeon/radeon_device.c
index 7a3daeb..857cf5b 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1093,7 +1093,7 @@ int radeon_device_init(struct radeon_device *rdev,
/* this will fail for cards that aren't VGA class devices, just
 * ignore it */
vga_client_register(rdev->pdev, rdev, NULL, radeon_vga_set_decode);
-   vga_switcheroo_register_client(rdev->pdev, &radeon_switcheroo_ops);
+   vga_switcheroo_register_client(rdev->pdev, &radeon_switcheroo_ops, 
false);
 
r = radeon_init(rdev);
if (r)
diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index e25cf31..efd147a 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -37,6 +37,7 @@ struct vga_switcheroo_client {
const struct vga_switcheroo_client_ops *ops;
int id;
bool active;
+   bool driver_power_control;
struct list_head list;
 };
 
@@ -132,7 +133,7 @@ EXPORT_SYMBOL(vga_switcheroo_unregister_handler);
 
 static int register_client(struct pci_dev *pdev,
   const struct vga_switcheroo_client_ops *ops,
-  int id, bool active)
+  int id, bool active, bool driver_power_control)
 {
struct vga_switcheroo_client *client;
 
@@ -145,6 +146,7 @@ static int register_client(struct pci_dev *pdev,
client->ops = ops;
client->id = id;
client->active = active;
+   client->driver_power_control = driver_power_control;
 
mutex_lock(&vgasr_mutex);
list_add_tail(&client->list, &vgasr_priv.clients);
@@ -160,10 +162,11 @@ static int register_client(struct pci_dev *pdev,
 }
 
 int vga_switcheroo_register_client(struct pci_dev *pdev,
-  const struct vga_switcheroo_client_ops *ops)
+  const struct vga_switcheroo_client_ops *ops,
+  bool driver_power_control)
 {
return register_client(pdev, ops, -1,
-  pdev == vga_default_device());
+  pdev == vga_default_device(), 
driver_power_control);
 }
 EXPORT_SYMBOL(vga_switcheroo_register_client);
 
@@ -171,7 +174,7 @@ int vga_switcheroo_register_audio_client(struct pci_dev 
*pdev,
 const struct vga_switcheroo_client_ops 
*ops,
 int id, bool active)
 {
-   return register_client(pdev, ops, id | ID_BIT_AUDIO, active);
+   return register_client(pdev, ops, id | ID_BIT_AUDIO, active, false);
 }
 EXPORT_SYMBOL(vga_switcheroo_register_audio_client);
 
@@ -258,10 +261,11 @@ static int vga_switcheroo_show(struct seq_file *m, void 
*v)
int i = 0;
mutex_lock(&vgasr_mutex);
list_for_each_entry(client, &vgasr_priv.clients, list) {
-   seq_printf(m, "%d:%s%s:%c:%s:%s\n", i,
+   seq_printf(m, "%d:%s%s:%c:%s%s:%s\n", i,
   client_id(client) == VGA_SWITCHEROO_DIS ? "DIS" : 
"IGD",
   client

[RFC] drm dynamic power off support

2012-09-09 Thread Dave Airlie
For optimus and powerxpress setups where we can explicitly power off
the GPU I'd like to do this under control of the driver. Now that I've
added X server support for secondary GPUs, it makes sense to start
powering them down more often if we can.

I've tested this code on two laptops, one intel/nouveau one intel/radeon
It works, powertop says I use 5-6W less power.

Caveats:
There is a race at X server start with platform probing code, if
the secondary device is off, we the wrong PCI info for it, I've
got a patch that works around this I'll send to the xorg-devel.

Audio seems to get screwed at least on one machine, we power up
and the alsa callbacks into snd_hda_intel get called but it can't
find the hw properly, need to investigate a bit further.

Dave.

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/5] nouveau: Add interface to detect optimus support

2012-09-09 Thread Dave Airlie
From: Dave Airlie 

This is required for later patches.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/nouveau/nouveau_acpi.c | 4 
 drivers/gpu/drm/nouveau/nouveau_acpi.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c 
b/drivers/gpu/drm/nouveau/nouveau_acpi.c
index e7369c8..b92833e 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -35,6 +35,10 @@ static struct nouveau_dsm_priv {
acpi_handle rom_handle;
 } nouveau_dsm_priv;
 
+bool nouveau_is_optimus(void) {
+   return nouveau_dsm_priv.optimus_detected;
+}
+
 #define NOUVEAU_DSM_HAS_MUX 0x1
 #define NOUVEAU_DSM_HAS_OPT 0x2
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.h 
b/drivers/gpu/drm/nouveau/nouveau_acpi.h
index 08af677..c70b4d1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.h
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.h
@@ -4,6 +4,7 @@
 #define ROM_BIOS_PAGE 4096
 
 #if defined(CONFIG_ACPI)
+bool nouveau_is_optimus(void);
 void nouveau_register_dsm_handler(void);
 void nouveau_unregister_dsm_handler(void);
 void nouveau_switcheroo_optimus_dsm(void);
@@ -11,6 +12,7 @@ int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, 
int len);
 bool nouveau_acpi_rom_supported(struct pci_dev *pdev);
 void *nouveau_acpi_edid(struct drm_device *, struct drm_connector *);
 #else
+static inline bool nouveau_is_optimus(void) { return false; };
 static inline void nouveau_register_dsm_handler(void) {}
 static inline void nouveau_unregister_dsm_handler(void) {}
 static inline void nouveau_switcheroo_optimus_dsm(void) {}
-- 
1.7.12

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/5] drm: Add initial dnyamic power off feature

2012-09-09 Thread Dave Airlie
From: Dave Airlie 

For secondary GPUs in laptops, i.e. optimus or powerxpress, we have
methods for powering down the GPU completely. This adds support
to the drm core for powering back up the GPU on any access from
ioctls or sysfs interfaces, and fires a 5s timer to test if
we can power the GPU off.

This is just an initial implementation to get discussions started!

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/drm_drv.c   | 68 +
 drivers/gpu/drm/drm_fb_helper.c |  2 +-
 drivers/gpu/drm/drm_fops.c  |  6 +++-
 drivers/gpu/drm/drm_stub.c  |  1 +
 drivers/gpu/drm/drm_sysfs.c |  4 +++
 include/drm/drmP.h  |  9 ++
 6 files changed, 88 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 9238de4..9fae62a 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -383,12 +383,17 @@ long drm_ioctl(struct file *filp,
char stack_kdata[128];
char *kdata = NULL;
unsigned int usize, asize;
+   int ret;
 
dev = file_priv->minor->dev;
 
if (drm_device_is_unplugged(dev))
return -ENODEV;
 
+   ret = drm_dynamic_power_wakeup(dev, __func__);
+   if (ret)
+   return ret;
+
atomic_inc(&dev->ioctl_count);
atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
++file_priv->ioctl_count;
@@ -494,3 +499,66 @@ struct drm_local_map *drm_getsarea(struct drm_device *dev)
return NULL;
 }
 EXPORT_SYMBOL(drm_getsarea);
+
+#define POWER_OFF_PERIOD (5*HZ)
+
+static void drm_dynamic_enable_poll(struct drm_device *dev)
+{
+   queue_delayed_work(system_nrt_wq, &dev->dynamic_power_poll, 
POWER_OFF_PERIOD);
+}
+
+static void drm_power_poll_execute(struct work_struct *work)
+{
+   struct delayed_work *delayed_work = to_delayed_work(work);
+   struct drm_device *dev = container_of(delayed_work, struct drm_device, 
dynamic_power_poll);
+   bool ret;
+
+   /* ask driver if okay to power off */
+   ret = dev->driver->dynamic_off_check(dev);
+   if (ret == false)
+   goto out_requeue;
+
+   ret = dev->driver->dynamic_set_state(dev, DRM_SWITCH_POWER_DYNAMIC_OFF);
+   DRM_INFO("powering down\n");
+   return;
+out_requeue:
+   queue_delayed_work(system_nrt_wq, delayed_work, POWER_OFF_PERIOD);
+}
+
+int drm_dynamic_power_wakeup(struct drm_device *dev, const char *reason)
+{
+   int ret;
+
+   if (!dev->driver->dynamic_off_check)
+   return 0;
+
+   cancel_delayed_work_sync(&dev->dynamic_power_poll);
+
+   ret = mutex_lock_interruptible(&dev->dynamic_power_lock);
+   if (ret) {
+   drm_dynamic_enable_poll(dev);
+   return ret;
+   }
+
+   if (dev->switch_power_state != DRM_SWITCH_POWER_DYNAMIC_OFF) {
+   mutex_unlock(&dev->dynamic_power_lock);
+   drm_dynamic_enable_poll(dev);
+   return 0;
+   }
+
+   DRM_INFO("waking up GPU for %s\n", reason);
+   ret = dev->driver->dynamic_set_state(dev, DRM_SWITCH_POWER_ON);
+   mutex_unlock(&dev->dynamic_power_lock);
+
+   drm_dynamic_enable_poll(dev);
+   return 0;
+}
+EXPORT_SYMBOL(drm_dynamic_power_wakeup);
+
+void drm_dynamic_power_init(struct drm_device *dev)
+{
+   INIT_DELAYED_WORK(&dev->dynamic_power_poll, drm_power_poll_execute);
+   if (dev->driver->dynamic_off_check)
+   drm_dynamic_enable_poll(dev);
+}
+EXPORT_SYMBOL(drm_dynamic_power_init);
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index f546d1e..9a2c56b 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -245,7 +245,7 @@ bool drm_fb_helper_force_kernel_mode(void)
return false;
 
list_for_each_entry(helper, &kernel_fb_helper_list, kernel_fb_list) {
-   if (helper->dev->switch_power_state == DRM_SWITCH_POWER_OFF)
+   if (helper->dev->switch_power_state == DRM_SWITCH_POWER_OFF || 
helper->dev->switch_power_state == DRM_SWITCH_POWER_DYNAMIC_OFF)
continue;
 
ret = drm_fb_helper_restore_fbdev_mode(helper);
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 5062eec..285e53f 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -239,9 +239,13 @@ static int drm_open_helper(struct inode *inode, struct 
file *filp,
return -EBUSY;  /* No exclusive opens */
if (!drm_cpu_valid())
return -EINVAL;
-   if (dev->switch_power_state != DRM_SWITCH_POWER_ON)
+   if (dev->switch_power_state != DRM_SWITCH_POWER_ON && 
dev->switch_power_state != DRM_SWITCH_POWER_DYNAMIC_OFF)
return -EINVAL;
 
+   ret = drm_dynamic_power_wakeup(dev, __func__);
+   if (ret)
+   return ret;
+
DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor_id);
 
p

[PATCH 4/5] nouveau: add dynamic gpu power off support.

2012-09-09 Thread Dave Airlie
From: Dave Airlie 

This adds the interfaces for nouveau to dynamically power off
the GPU in an optimus system.

It's based on nouveau git so may not apply everywhere.

Signed-off-by: Dave Airlie 
 #include 
 #include 
-
+#include 
 #include "drmP.h"
-
+#include "drm_crtc_helper.h"
 #include "nouveau_drm.h"
 #include "nouveau_pm.h"
-
+#include "nouveau_acpi.h"
 #include 
 #include 
 #include 
@@ -962,6 +962,7 @@ nouveau_pm_init(struct drm_device *dev)
register_acpi_notifier(&pm->acpi_nb);
 #endif
 
+   drm_dynamic_power_init(dev);
return 0;
 }
 
@@ -1007,3 +1008,53 @@ nouveau_pm_resume(struct drm_device *dev)
nouveau_pm_perflvl_set(dev, perflvl);
nouveau_pwmfan_set(dev, pm->fan.percent);
 }
+
+/* rules for what we want
+   if we are an optimus laptop,
+   with no active crtc/encoders/connectors
+   with no channel activity for 4-5s
+*/
+
+bool nouveau_dynamic_power_check(struct drm_device *dev)
+{
+   struct nouveau_drm *drm = nouveau_drm(dev);
+   struct drm_crtc *crtc;
+
+   /* are we optimus enabled? */
+   if (!nouveau_is_optimus()) {
+   DRM_DEBUG_DRIVER("failing to power off - not optimus\n");
+   return false;
+   }
+
+   list_for_each_entry(crtc, &drm->dev->mode_config.crtc_list, head) {
+   if (crtc->enabled) {
+   DRM_DEBUG_DRIVER("failing to power off - crtc 
active\n");
+   return false;
+   }
+   }
+   return true;
+}
+
+int nouveau_dynamic_power_set_state(struct drm_device *dev, int state)
+{
+   struct nouveau_drm *drm = nouveau_drm(dev);
+   pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
+
+   if (state == DRM_SWITCH_POWER_DYNAMIC_OFF) {
+   dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
+   drm_kms_helper_poll_disable(drm->dev);
+   vga_switcheroo_set_dynamic_switch(dev->pdev, 
VGA_SWITCHEROO_OFF, false);
+   nouveau_switcheroo_optimus_dsm();
+   nouveau_drm_suspend(drm->dev->pdev, pmm);
+   vga_switcheroo_set_dynamic_switch(dev->pdev, 
VGA_SWITCHEROO_OFF, true);
+   } else if (state == DRM_SWITCH_POWER_ON) {
+   vga_switcheroo_set_dynamic_switch(dev->pdev, VGA_SWITCHEROO_ON, 
true);
+   nouveau_drm_resume(dev->pdev);
+   vga_switcheroo_set_dynamic_switch(dev->pdev, VGA_SWITCHEROO_ON, 
false);
+   drm_kms_helper_poll_enable(dev);
+   dev->switch_power_state = DRM_SWITCH_POWER_ON;
+   }
+
+   return 0;
+}
+
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c 
b/drivers/gpu/drm/nouveau/nouveau_vga.c
index 37fcc9d..539722f 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -33,6 +33,8 @@ nouveau_switcheroo_set_state(struct pci_dev *pdev,
struct drm_device *dev = pci_get_drvdata(pdev);
pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
 
+   if (nouveau_is_optimus() && state == VGA_SWITCHEROO_OFF)
+   return;
if (state == VGA_SWITCHEROO_ON) {
printk(KERN_ERR "VGA switcheroo: switched nouveau on\n");
dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
@@ -80,7 +82,7 @@ nouveau_vga_init(struct nouveau_drm *drm)
 {
struct drm_device *dev = drm->dev;
vga_client_register(dev->pdev, dev, NULL, nouveau_vga_set_decode);
-   vga_switcheroo_register_client(dev->pdev, &nouveau_switcheroo_ops, 
false);
+   vga_switcheroo_register_client(dev->pdev, &nouveau_switcheroo_ops, 
nouveau_is_optimus());
 }
 
 void
-- 
1.7.12

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5/5] radeon: add dynamic power off support

2012-09-09 Thread Dave Airlie
From: Dave Airlie 

This adds the start of dynamic power off support to radeon,
it probably turns off way to many GPUs but is an initial implementation
I've tested on an gm45/rv635 combination laptop.

Signed-off-by: Dave Airlie 
---
 drivers/gpu/drm/radeon/radeon.h|  3 +++
 drivers/gpu/drm/radeon/radeon_device.c |  2 +-
 drivers/gpu/drm/radeon/radeon_drv.c|  6 ++
 drivers/gpu/drm/radeon/radeon_pm.c | 37 +-
 4 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 59a1531..0abad51 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -1839,6 +1839,9 @@ extern int radeon_acpi_init(struct radeon_device *rdev);
 static inline int radeon_acpi_init(struct radeon_device *rdev) { return 0; } 
 #endif 
 
+extern bool radeon_dynamic_power_check(struct drm_device *dev);
+extern int radeon_dynamic_power_set_state(struct drm_device *dev, int state);
+
 #include "radeon_object.h"
 
 #endif
diff --git a/drivers/gpu/drm/radeon/radeon_device.c 
b/drivers/gpu/drm/radeon/radeon_device.c
index 857cf5b..c58849c 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1093,7 +1093,7 @@ int radeon_device_init(struct radeon_device *rdev,
/* this will fail for cards that aren't VGA class devices, just
 * ignore it */
vga_client_register(rdev->pdev, rdev, NULL, radeon_vga_set_decode);
-   vga_switcheroo_register_client(rdev->pdev, &radeon_switcheroo_ops, 
false);
+   vga_switcheroo_register_client(rdev->pdev, &radeon_switcheroo_ops, 
true);
 
r = radeon_init(rdev);
if (r)
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index 8c593ea..b0a7211 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -118,6 +118,9 @@ struct dma_buf *radeon_gem_prime_export(struct drm_device 
*dev,
 struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev,
   struct dma_buf *dma_buf);
 
+bool radeon_dynamic_power_check(struct drm_device *dev);
+int radeon_dynamic_power_set_state(struct drm_device *dev, int state);
+
 #if defined(CONFIG_DEBUG_FS)
 int radeon_debugfs_init(struct drm_minor *minor);
 void radeon_debugfs_cleanup(struct drm_minor *minor);
@@ -385,6 +388,9 @@ static struct drm_driver kms_driver = {
.gem_prime_export = radeon_gem_prime_export,
.gem_prime_import = radeon_gem_prime_import,
 
+   .dynamic_off_check = radeon_dynamic_power_check,
+   .dynamic_set_state = radeon_dynamic_power_set_state,
+
.name = DRIVER_NAME,
.desc = DRIVER_DESC,
.date = DRIVER_DATE,
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c 
b/drivers/gpu/drm/radeon/radeon_pm.c
index 7ae6066..2763ff1 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -30,7 +30,7 @@
 #include 
 #include 
 #include 
-
+#include 
 #define RADEON_IDLE_LOOP_MS 100
 #define RADEON_RECLOCK_DELAY_MS 200
 #define RADEON_WAIT_VBLANK_TIMEOUT 200
@@ -643,6 +643,8 @@ int radeon_pm_init(struct radeon_device *rdev)
DRM_INFO("radeon: power management initialized\n");
}
 
+   drm_dynamic_power_init(rdev->ddev);
+
return 0;
 }
 
@@ -877,3 +879,36 @@ static int radeon_debugfs_pm_init(struct radeon_device 
*rdev)
return 0;
 #endif
 }
+
+bool radeon_dynamic_power_check(struct drm_device *dev)
+{
+   struct drm_crtc *crtc;
+
+   list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+   if (crtc->enabled) {
+   DRM_DEBUG_DRIVER("failing to power off - crtc 
active\n");
+   return false;
+   }
+   }
+   return true;
+}
+
+int radeon_dynamic_power_set_state(struct drm_device *dev, int state)
+{
+   pm_message_t pmm = { .event = PM_EVENT_SUSPEND };
+
+   if (state == DRM_SWITCH_POWER_DYNAMIC_OFF) {
+   dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
+   vga_switcheroo_set_dynamic_switch(dev->pdev, 
VGA_SWITCHEROO_OFF, false);
+   drm_kms_helper_poll_disable(dev);
+   radeon_suspend_kms(dev, pmm);
+   vga_switcheroo_set_dynamic_switch(dev->pdev, 
VGA_SWITCHEROO_OFF, true);
+   } else {
+   vga_switcheroo_set_dynamic_switch(dev->pdev, VGA_SWITCHEROO_ON, 
true);
+   radeon_resume_kms(dev);
+   vga_switcheroo_set_dynamic_switch(dev->pdev, VGA_SWITCHEROO_ON, 
false);
+   drm_kms_helper_poll_enable(dev);
+   dev->switch_power_state = DRM_SWITCH_POWER_ON;
+   }
+   return 0;
+}
-- 
1.7.12

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [RFC] drm dynamic power off support

2012-09-09 Thread Dave Airlie
On Mon, Sep 10, 2012 at 2:31 PM, Dave Airlie  wrote:
> For optimus and powerxpress setups where we can explicitly power off
> the GPU I'd like to do this under control of the driver. Now that I've
> added X server support for secondary GPUs, it makes sense to start
> powering them down more often if we can.
>
> I've tested this code on two laptops, one intel/nouveau one intel/radeon
> It works, powertop says I use 5-6W less power.
>
> Caveats:
> There is a race at X server start with platform probing code, if
> the secondary device is off, we the wrong PCI info for it, I've
> got a patch that works around this I'll send to the xorg-devel.
>
> Audio seems to get screwed at least on one machine, we power up
> and the alsa callbacks into snd_hda_intel get called but it can't
> find the hw properly, need to investigate a bit further.
>
> Dave.
>
Hi Takashi,

just wondering how well setup alsa would be for the dGPU powering
up/down a lot more often,
  139.529103] nouveau  [ DRM][:01:00.0] resuming display...
[  139.833960] ALSA sound/pci/hda/hda_intel.c:2533 Enabling
:01:00.1 via VGA-switcheroo
[  139.844789] snd_hda_intel :01:00.1: Refused to change power
state, currently in D3
[  139.915760] snd_hda_intel :01:00.1: Refused to change power
state, currently in D3
[  140.917437] ALSA sound/pci/hda/hda_intel.c:813 spurious response
0x0:0x3, last cmd=0x301f0500
[  140.917449] ALSA sound/pci/hda/hda_intel.c:813 spurious response
0x0:0x3, last cmd=0x301f0500
[  140.917455] ALSA sound/pci/hda/hda_intel.c:813 spurious response
0x0:0x3, last cmd=0x301f0500
[  140.917460] ALSA sound/pci/hda/hda_intel.c:813 spurious response
0x0:0x3, last cmd=0x301f0500
[  140.917465] ALSA sound/pci/hda/hda_intel.c:813 spurious response
0x0:0x3, last cmd=0x301f0500

is just some of the things I see, if I turn off before snd_hda_intel,
things go badly wrong when
I do power up the dGPU, if I delay the power off until audio is
loaded, I start to see wierd things when pulseaudio starts when the
dGPU is off.

Dave.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[git pull] drm fixes

2012-09-09 Thread Dave Airlie

Hi Linus,

just noticed I hadn't send these out, nothing majorly urgent, I know AMD 
guys have some regression fixes coming soon,

This contains:
2 nouveau fixes so it loads on the retina MBP systems properly,
2 vmwgfx fixes to load the driver earlier, and allow distros config it
1 error->debug fix in ast
and Keith was playing with 32-on-64 and decided we may as well stick the 
compat ioctl in all the drivers. It fixes udl for him.

Dave.

The following changes since commit 4cbe5a555fa58a79b6ecbb6c531b8bab0650778d:

  Linux 3.6-rc4 (2012-09-01 10:39:58 -0700)

are available in the git repository at:

  git://people.freedesktop.org/~airlied/linux.git drm-fixes

for you to fetch changes up to c4903429a92be60e6fe59868924a65eca4cd1a38:

  drm/vmwgfx: add MODULE_DEVICE_TABLE so vmwgfx loads at boot (2012-09-07 
13:25:34 +1000)


Ben Skeggs (2):
  drm/nvd0/disp: hopefully fix selection of 6/8bpc mode on DP outputs
  drm/nv50-/gpio: initialise to vbios defaults during init

Dave Airlie (4):
  Merge branch 'drm-nouveau-fixes' of 
git://anongit.freedesktop.org/nouveau/linux-2.6 into drm-fixes
  drm/ast: drop debug level on error printk
  drm/vmwgfx: allow a kconfig option to choose if fbcon is enabled
  drm/vmwgfx: add MODULE_DEVICE_TABLE so vmwgfx loads at boot

Keith Packard (1):
  drm: use drm_compat_ioctl for 32-bit apps

 drivers/gpu/drm/ast/ast_drv.c   |3 +++
 drivers/gpu/drm/ast/ast_mode.c  |2 +-
 drivers/gpu/drm/cirrus/cirrus_drv.c |3 +++
 drivers/gpu/drm/exynos/exynos_drm_drv.c |3 +++
 drivers/gpu/drm/i810/i810_dma.c |3 +++
 drivers/gpu/drm/i810/i810_drv.c |3 +++
 drivers/gpu/drm/mgag200/mgag200_drv.c   |3 +++
 drivers/gpu/drm/nouveau/nv50_gpio.c |3 +++
 drivers/gpu/drm/nouveau/nvd0_display.c  |4 ++--
 drivers/gpu/drm/savage/savage_drv.c |3 +++
 drivers/gpu/drm/sis/sis_drv.c   |3 +++
 drivers/gpu/drm/tdfx/tdfx_drv.c |3 +++
 drivers/gpu/drm/udl/udl_drv.c   |3 +++
 drivers/gpu/drm/via/via_drv.c   |3 +++
 drivers/gpu/drm/vmwgfx/Kconfig  |8 
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c |3 ++-
 16 files changed, 49 insertions(+), 4 deletions(-)
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[GIT PULL] exynos-drm-fixes

2012-09-09 Thread Inki Dae
Hello Dave, sorry for being late.

this patch set fixes build warnings and includes minor code cleanup and
also one patch you missed. this patch just drops non-standard NV12M and
YUV420M formats from drm_fourcc.h
for this, you can refer to below link:
http://lists.freedesktop.org/archives/dri-devel/2012-April/021812.html

other patches including big changes will go to -next.

Highlights:
- fix build warnings
- minor code cleanup
- remove non-standard format, DRM_FORMAT_NV12M
- add dummy mmap for exynos dmabuf
  . dma_buf export needs this patch

if there is any problem, please let me know.

Thanks.
Inki Dae

The following changes since commit df5c2b713f6bda08f7d668fe5b95a36a4b70a000:

  Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux into 
drm-fixes (2012-09-07 15:35:27 +0900)

are available in the git repository at:

  git://git.infradead.org/users/kmpark/linux-samsung exynos-drm-fixes

Inki Dae (2):
  drm/exynos: fixed page align bug.
  drm/exynos: remove DRM_FORMAT_NV12M from plane module

Mandeep Singh Baines (1):
  drm/exynos: fix double call of drm_prime_(init/destroy)_file_private

Sachin Kamat (9):
  drm/exynos: Remove redundant check in exynos_hdmi.c file
  drm/exynos: Remove redundant check in exynos_drm_fimd.c file
  drm/exynos: Use devm_kzalloc in exynos_drm_vidi.c file
  drm/exynos: Use devm_kzalloc in exynos_drm_hdmi.c file
  drm/exynos: Use devm_* functions in exynos_drm_g2d.c file
  drm/exynos: Add dependency for G2D in Kconfig
  drm/exynos: Make g2d_pm_ops static
  drm/exynos: Add missing braces around sizeof in exynos_hdmi.c
  drm/exynos: Add missing braces around sizeof in exynos_mixer.c

Thomas Meyer (1):
  drm/exynos: Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(.. 
[1]

Tomasz Stanislawski (1):
  drm/exynos: add dummy support for dmabuf-mmap

Ville Syrjälä (1):
  drm: Drop the NV12M and YUV420M formats

 drivers/gpu/drm/exynos/Kconfig |2 +-
 drivers/gpu/drm/exynos/exynos_drm_dmabuf.c |7 
 drivers/gpu/drm/exynos/exynos_drm_drv.c|2 -
 drivers/gpu/drm/exynos/exynos_drm_fimd.c   |5 ---
 drivers/gpu/drm/exynos/exynos_drm_g2d.c|   52 ++--
 drivers/gpu/drm/exynos/exynos_drm_gem.c|4 +-
 drivers/gpu/drm/exynos/exynos_drm_hdmi.c   |3 +-
 drivers/gpu/drm/exynos/exynos_drm_plane.c  |1 -
 drivers/gpu/drm/exynos/exynos_drm_vidi.c   |4 +--
 drivers/gpu/drm/exynos/exynos_hdmi.c   |   11 ++
 drivers/gpu/drm/exynos/exynos_mixer.c  |6 ++--
 include/drm/drm_fourcc.h   |6 +---
 12 files changed, 30 insertions(+), 73 deletions(-)
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/omap: add more new timings fields

2012-09-09 Thread Tomi Valkeinen
On Fri, 2012-09-07 at 12:59 -0500, Rob Clark wrote:
> From: Rob Clark 
> 
> Without these, DVI is broken.
> 
> Signed-off-by: Rob Clark 
> ---
> Greg, it looks like the omapdss changes which added these fields, as
> well as the interlaced field, where merged in Linux 3.5-rc5.  So I
> think both this and the 'update for interlaced' patch are needed for
> both 3.6 and 3.5.

The omapdss timing and interlace changes were merged in 3.6 merge
window, they were not merged in 3.5 merge window (and even less in
3.5-rc5)...

 Tomi



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 0/7] Fixes for hybrid graphics Apple machines

2012-09-09 Thread Seth Forshee
Many hybrid graphics Apple laptops fail to set up LVDS on the secondary
GPU due to missing or incorrect mode information for the panel at init
time. The only way to get the LVDS mode on these machines is via the
DDC, but this is muxed to the active GPU at boot. However, the graphics
mux on these machines supports muxing the i2c idependently of the
display, making it possible for the secondary graphics driver to read
the EDID without a full display switch.

In order to support this, these patches modify vga_switcheroo to allow
muxing of the DDC idependently of the display. apple-gmux is updated to
support this new functionality, and drm_get_edid() is modified to switch
the DDC mux as needed.

For this to work we also need to ensure that sufficient switcheroo
suport is available before initializing the secondary GPU. This is done
by adding any non-active GPUs that try to initialize before switcheroo
is ready to a list and initializing these devices once switcheroo
becomes ready. This behavior is restricted to Apple laptops to prevent
causing problems on other machines.

Thanks,
Seth

Seth Forshee (7):
  vga_switcheroo: Add support for switching only the DDC
  vga_switcheroo: Add helper function to get the active client
  vga_switcheroo: Add notifier call chain for switcheroo events
  apple-gmux: Add switch_ddc support
  drm/edid: Switch DDC when reading the EDID
  drm/pci: Add drm_put_pci_dev()
  drm/pci: Defer initialization of secondary graphics devices until
switcheroo is ready

 drivers/gpu/drm/ast/ast_drv.c |2 +-
 drivers/gpu/drm/cirrus/cirrus_drv.c   |2 +-
 drivers/gpu/drm/drm_drv.c |3 +
 drivers/gpu/drm/drm_edid.c|   17 
 drivers/gpu/drm/drm_pci.c |  172 +
 drivers/gpu/drm/gma500/psb_drv.c  |2 +-
 drivers/gpu/drm/i915/i915_drv.c   |2 +-
 drivers/gpu/drm/mgag200/mgag200_drv.c |2 +-
 drivers/gpu/drm/nouveau/nouveau_drv.c |2 +-
 drivers/gpu/drm/radeon/radeon_drv.c   |2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   |2 +-
 drivers/gpu/vga/vga_switcheroo.c  |   87 -
 drivers/platform/x86/apple-gmux.c |   12 ++-
 include/drm/drmP.h|3 +
 include/linux/vga_switcheroo.h|   20 
 15 files changed, 302 insertions(+), 28 deletions(-)

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/7] vga_switcheroo: Add support for switching only the DDC

2012-09-09 Thread Seth Forshee
During graphics driver initialization its useful to be able to mux only
the DDC to the inactive client in order to read the EDID. Add a
switch_ddc callback to allow capable handlers to provide this
functionality, and add vga_switcheroo_switch_ddc() to allow DRM to mux
only the DDC.

Signed-off-by: Seth Forshee 
---
 drivers/gpu/vga/vga_switcheroo.c |   39 +-
 include/linux/vga_switcheroo.h   |4 
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index e25cf31..ea6bcc2 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -252,6 +252,29 @@ void vga_switcheroo_client_fb_set(struct pci_dev *pdev,
 }
 EXPORT_SYMBOL(vga_switcheroo_client_fb_set);
 
+int vga_switcheroo_switch_ddc(struct pci_dev *pdev)
+{
+   int ret = 0;
+   int id;
+
+   mutex_lock(&vgasr_mutex);
+
+   if (!vgasr_priv.handler) {
+   ret = -ENODEV;
+   goto out;
+   }
+
+   if (vgasr_priv.handler->switch_ddc) {
+   id = vgasr_priv.handler->get_client_id(pdev);
+   ret = vgasr_priv.handler->switch_ddc(id);
+   }
+
+out:
+   mutex_unlock(&vgasr_mutex);
+   return ret;
+}
+EXPORT_SYMBOL(vga_switcheroo_switch_ddc);
+
 static int vga_switcheroo_show(struct seq_file *m, void *v)
 {
struct vga_switcheroo_client *client;
@@ -342,9 +365,15 @@ static int vga_switchto_stage2(struct 
vga_switcheroo_client *new_client)
fb_notifier_call_chain(FB_EVENT_REMAP_ALL_CONSOLE, &event);
}
 
+   if (vgasr_priv.handler->switch_ddc) {
+   ret = vgasr_priv.handler->switch_ddc(new_client->id);
+   if (ret)
+   return ret;
+   }
+
ret = vgasr_priv.handler->switchto(new_client->id);
if (ret)
-   return ret;
+   goto restore_ddc;
 
if (new_client->ops->reprobe)
new_client->ops->reprobe(new_client->pdev);
@@ -356,6 +385,14 @@ static int vga_switchto_stage2(struct 
vga_switcheroo_client *new_client)
 
new_client->active = true;
return 0;
+
+restore_ddc:
+   if (vgasr_priv.handler->switch_ddc) {
+   int id = (new_client->id == VGA_SWITCHEROO_IGD) ?
+   VGA_SWITCHEROO_DIS : VGA_SWITCHEROO_IGD;
+   ret = vgasr_priv.handler->switch_ddc(id);
+   }
+   return ret;
 }
 
 static bool check_can_switch(void)
diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
index ddb419c..b0d0839 100644
--- a/include/linux/vga_switcheroo.h
+++ b/include/linux/vga_switcheroo.h
@@ -29,6 +29,7 @@ enum vga_switcheroo_client_id {
 };
 
 struct vga_switcheroo_handler {
+   int (*switch_ddc)(enum vga_switcheroo_client_id id);
int (*switchto)(enum vga_switcheroo_client_id id);
int (*power_state)(enum vga_switcheroo_client_id id,
   enum vga_switcheroo_state state);
@@ -53,6 +54,8 @@ int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
 void vga_switcheroo_client_fb_set(struct pci_dev *dev,
  struct fb_info *info);
 
+int vga_switcheroo_switch_ddc(struct pci_dev *pdev);
+
 int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler);
 void vga_switcheroo_unregister_handler(void);
 
@@ -66,6 +69,7 @@ static inline void vga_switcheroo_unregister_client(struct 
pci_dev *dev) {}
 static inline int vga_switcheroo_register_client(struct pci_dev *dev,
const struct vga_switcheroo_client_ops *ops) { return 0; }
 static inline void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct 
fb_info *info) {}
+static inline void vga_switcheroo_switch_ddc(struct pci_dev *pdev) { return 
NULL; }
 static inline int vga_switcheroo_register_handler(struct 
vga_switcheroo_handler *handler) { return 0; }
 static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
const struct vga_switcheroo_client_ops *ops,
-- 
1.7.9.5

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/7] vga_switcheroo: Add helper function to get the active client

2012-09-09 Thread Seth Forshee
Add vga_switcheroo_get_active_client() to allow drivers to get the
active video client. This will be used by drivers wishing to temporarily
mux only the DDC to the inactive client.

Signed-off-by: Seth Forshee 
---
 drivers/gpu/vga/vga_switcheroo.c |   14 ++
 include/linux/vga_switcheroo.h   |2 ++
 2 files changed, 16 insertions(+)

diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index ea6bcc2..e53f67d 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -205,6 +205,20 @@ find_active_client(struct list_head *head)
return NULL;
 }
 
+struct pci_dev *vga_switcheroo_get_active_client(void)
+{
+   struct vga_switcheroo_client *client;
+   struct pci_dev *pdev = NULL;
+
+   mutex_lock(&vgasr_mutex);
+   client = find_active_client(&vgasr_priv.clients);
+   if (client)
+   pdev = client->pdev;
+   mutex_unlock(&vgasr_mutex);
+   return pdev;
+}
+EXPORT_SYMBOL(vga_switcheroo_get_active_client);
+
 int vga_switcheroo_get_client_state(struct pci_dev *pdev)
 {
struct vga_switcheroo_client *client;
diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
index b0d0839..e361858 100644
--- a/include/linux/vga_switcheroo.h
+++ b/include/linux/vga_switcheroo.h
@@ -61,6 +61,7 @@ void vga_switcheroo_unregister_handler(void);
 
 int vga_switcheroo_process_delayed_switch(void);
 
+struct pci_dev *vga_switcheroo_get_active_client(void);
 int vga_switcheroo_get_client_state(struct pci_dev *dev);
 
 #else
@@ -76,6 +77,7 @@ static inline int vga_switcheroo_register_audio_client(struct 
pci_dev *pdev,
int id, bool active) { return 0; }
 static inline void vga_switcheroo_unregister_handler(void) {}
 static inline int vga_switcheroo_process_delayed_switch(void) { return 0; }
+static inline struct pci_dev *vga_switcheroo_get_active_client(void) { return 
NULL; }
 static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { 
return VGA_SWITCHEROO_ON; }
 
 
-- 
1.7.9.5

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/7] vga_switcheroo: Add notifier call chain for switcheroo events

2012-09-09 Thread Seth Forshee
DRM needs to be notified of client and handler registration in order to
defer initialization of the secondary GPU until the EDID can be read
from the LVDS panel. To support this add a notifier call chain to
vga_switcheroo for subscribing to switcheroo events. Events are
generated for registration and unregistration of handlers and clients.

Signed-off-by: Seth Forshee 
---
 drivers/gpu/vga/vga_switcheroo.c |   34 ++
 include/linux/vga_switcheroo.h   |   14 ++
 2 files changed, 48 insertions(+)

diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index e53f67d..d5cd274 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -70,6 +71,28 @@ static struct vgasr_priv vgasr_priv = {
.clients = LIST_HEAD_INIT(vgasr_priv.clients),
 };
 
+static BLOCKING_NOTIFIER_HEAD(vga_switcheroo_notifier_list);
+
+int vga_switcheroo_register_notifier(struct notifier_block *nb)
+{
+   return blocking_notifier_chain_register(&vga_switcheroo_notifier_list,
+   nb);
+}
+EXPORT_SYMBOL(vga_switcheroo_register_notifier);
+
+int vga_switcheroo_unregister_notifier(struct notifier_block *nb)
+{
+   return blocking_notifier_chain_unregister(&vga_switcheroo_notifier_list,
+ nb);
+}
+EXPORT_SYMBOL(vga_switcheroo_unregister_notifier);
+
+static int vga_switcheroo_notifier_call_chain(enum vga_switcheroo_event event)
+{
+   return blocking_notifier_call_chain(&vga_switcheroo_notifier_list,
+   event, NULL);
+}
+
 static bool vga_switcheroo_ready(void)
 {
/* we're ready if we get two clients + handler */
@@ -113,10 +136,18 @@ int vga_switcheroo_register_handler(struct 
vga_switcheroo_handler *handler)
vga_switcheroo_enable();
}
mutex_unlock(&vgasr_mutex);
+
+   vga_switcheroo_notifier_call_chain(VGA_SWITCHEROO_HANDLER_REGISTERED);
return 0;
 }
 EXPORT_SYMBOL(vga_switcheroo_register_handler);
 
+bool vga_switcheroo_handler_registered(void)
+{
+   return !!vgasr_priv.handler;
+}
+EXPORT_SYMBOL(vga_switcheroo_handler_registered);
+
 void vga_switcheroo_unregister_handler(void)
 {
mutex_lock(&vgasr_mutex);
@@ -127,6 +158,7 @@ void vga_switcheroo_unregister_handler(void)
vgasr_priv.active = false;
}
mutex_unlock(&vgasr_mutex);
+   vga_switcheroo_notifier_call_chain(VGA_SWITCHEROO_HANDLER_UNREGISTERED);
 }
 EXPORT_SYMBOL(vga_switcheroo_unregister_handler);
 
@@ -156,6 +188,7 @@ static int register_client(struct pci_dev *pdev,
vga_switcheroo_enable();
}
mutex_unlock(&vgasr_mutex);
+   vga_switcheroo_notifier_call_chain(VGA_SWITCHEROO_CLIENT_REGISTERED);
return 0;
 }
 
@@ -250,6 +283,7 @@ void vga_switcheroo_unregister_client(struct pci_dev *pdev)
vgasr_priv.active = false;
}
mutex_unlock(&vgasr_mutex);
+   vga_switcheroo_notifier_call_chain(VGA_SWITCHEROO_CLIENT_UNREGISTERED);
 }
 EXPORT_SYMBOL(vga_switcheroo_unregister_client);
 
diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
index e361858..c3d7c6f 100644
--- a/include/linux/vga_switcheroo.h
+++ b/include/linux/vga_switcheroo.h
@@ -11,6 +11,7 @@
 #define _LINUX_VGA_SWITCHEROO_H_
 
 #include 
+#include 
 
 struct pci_dev;
 
@@ -28,6 +29,13 @@ enum vga_switcheroo_client_id {
VGA_SWITCHEROO_MAX_CLIENTS,
 };
 
+enum vga_switcheroo_event {
+   VGA_SWITCHEROO_CLIENT_REGISTERED,
+   VGA_SWITCHEROO_CLIENT_UNREGISTERED,
+   VGA_SWITCHEROO_HANDLER_REGISTERED,
+   VGA_SWITCHEROO_HANDLER_UNREGISTERED,
+};
+
 struct vga_switcheroo_handler {
int (*switch_ddc)(enum vga_switcheroo_client_id id);
int (*switchto)(enum vga_switcheroo_client_id id);
@@ -44,6 +52,9 @@ struct vga_switcheroo_client_ops {
 };
 
 #if defined(CONFIG_VGA_SWITCHEROO)
+int vga_switcheroo_register_notifier(struct notifier_block *nb);
+int vga_switcheroo_unregister_notifier(struct notifier_block *nb);
+bool vga_switcheroo_handler_registered(void);
 void vga_switcheroo_unregister_client(struct pci_dev *dev);
 int vga_switcheroo_register_client(struct pci_dev *dev,
   const struct vga_switcheroo_client_ops *ops);
@@ -66,6 +77,9 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
 
 #else
 
+static inline int vga_switcheroo_register_notifier(struct notifier_block *nb) 
{ return 0; }
+static inline int vga_switcheroo_unregister_notifier(struct notifier_block 
*nb) { return 0; }
+static inline bool vga_switcheroo_handler_registered(void) { return false; }
 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
 static inline int vga_switcheroo_register_client(struct pci_dev *dev,
const struct 

[PATCH 4/7] apple-gmux: Add switch_ddc support

2012-09-09 Thread Seth Forshee
The gmux allows muxing the DDC independently from the display, so
support this functionality. This will allow reading the EDID for the
inactive GPU, fixing issues with machines that either don't have a VBT
or have invalid mode data in the VBT.

Signed-off-by: Seth Forshee 
---
 drivers/platform/x86/apple-gmux.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/apple-gmux.c 
b/drivers/platform/x86/apple-gmux.c
index dfb1a92..d1e372d 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -269,14 +269,21 @@ static const struct backlight_ops gmux_bl_ops = {
.update_status = gmux_update_status,
 };
 
+static int gmux_switch_ddc(enum vga_switcheroo_client_id id)
+{
+   if (id == VGA_SWITCHEROO_IGD)
+   gmux_write8(apple_gmux_data, GMUX_PORT_SWITCH_DDC, 1);
+   else
+   gmux_write8(apple_gmux_data, GMUX_PORT_SWITCH_DDC, 2);
+   return 0;
+}
+
 static int gmux_switchto(enum vga_switcheroo_client_id id)
 {
if (id == VGA_SWITCHEROO_IGD) {
-   gmux_write8(apple_gmux_data, GMUX_PORT_SWITCH_DDC, 1);
gmux_write8(apple_gmux_data, GMUX_PORT_SWITCH_DISPLAY, 2);
gmux_write8(apple_gmux_data, GMUX_PORT_SWITCH_EXTERNAL, 2);
} else {
-   gmux_write8(apple_gmux_data, GMUX_PORT_SWITCH_DDC, 2);
gmux_write8(apple_gmux_data, GMUX_PORT_SWITCH_DISPLAY, 3);
gmux_write8(apple_gmux_data, GMUX_PORT_SWITCH_EXTERNAL, 3);
}
@@ -343,6 +350,7 @@ gmux_active_client(struct apple_gmux_data *gmux_data)
 }
 
 static struct vga_switcheroo_handler gmux_handler = {
+   .switch_ddc = gmux_switch_ddc,
.switchto = gmux_switchto,
.power_state = gmux_set_power_state,
.get_client_id = gmux_get_client_id,
-- 
1.7.9.5

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5/7] drm/edid: Switch DDC when reading the EDID

2012-09-09 Thread Seth Forshee
Some dual graphics machines support muxing the DDC separately from the
display, so make use of this functionality when reading the EDID on the
inactive GPU. Also serialize drm_get_edid() with a mutex to avoid races
on the DDC mux state.

Signed-off-by: Seth Forshee 
---
 drivers/gpu/drm/drm_edid.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index b7ee230..b389269 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -31,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "drmP.h"
 #include "drm_edid.h"
 #include "drm_edid_modes.h"
@@ -82,6 +83,8 @@ struct detailed_mode_closure {
 #define LEVEL_GTF2 2
 #define LEVEL_CVT  3
 
+static DEFINE_MUTEX(drm_edid_mutex);
+
 static struct edid_quirk {
char vendor[4];
int product_id;
@@ -398,12 +401,26 @@ struct edid *drm_get_edid(struct drm_connector *connector,
  struct i2c_adapter *adapter)
 {
struct edid *edid = NULL;
+   struct pci_dev *pdev = connector->dev->pdev;
+   struct pci_dev *active_pdev = NULL;
+
+   mutex_lock(&drm_edid_mutex);
+
+   if (pdev) {
+   active_pdev = vga_switcheroo_get_active_client();
+   if (active_pdev != pdev)
+   vga_switcheroo_switch_ddc(pdev);
+   }
 
if (drm_probe_ddc(adapter))
edid = (struct edid *)drm_do_get_edid(connector, adapter);
 
+   if (active_pdev && active_pdev != pdev)
+   vga_switcheroo_switch_ddc(active_pdev);
+
connector->display_info.raw_edid = (char *)edid;
 
+   mutex_unlock(&drm_edid_mutex);
return edid;
 
 }
-- 
1.7.9.5

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 6/7] drm/pci: Add drm_put_pci_dev()

2012-09-09 Thread Seth Forshee
When deferred initialization support for pci devices is added some
additional cleanup will be needed. Add a pci-specific put function to
serve this purpose, and convert the pci drivers over to using it. For
now it just calls drm_put_dev(), so this commit has no functional
change.

Signed-off-by: Seth Forshee 
---
 drivers/gpu/drm/ast/ast_drv.c |2 +-
 drivers/gpu/drm/cirrus/cirrus_drv.c   |2 +-
 drivers/gpu/drm/drm_pci.c |8 +++-
 drivers/gpu/drm/gma500/psb_drv.c  |2 +-
 drivers/gpu/drm/i915/i915_drv.c   |2 +-
 drivers/gpu/drm/mgag200/mgag200_drv.c |2 +-
 drivers/gpu/drm/nouveau/nouveau_drv.c |2 +-
 drivers/gpu/drm/radeon/radeon_drv.c   |2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   |2 +-
 include/drm/drmP.h|1 +
 10 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c
index d0c4574..001298d 100644
--- a/drivers/gpu/drm/ast/ast_drv.c
+++ b/drivers/gpu/drm/ast/ast_drv.c
@@ -72,7 +72,7 @@ ast_pci_remove(struct pci_dev *pdev)
 {
struct drm_device *dev = pci_get_drvdata(pdev);
 
-   drm_put_dev(dev);
+   drm_put_pci_dev(dev);
 }
 
 
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c 
b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 7053140..c7ca02b 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -64,7 +64,7 @@ static void cirrus_pci_remove(struct pci_dev *pdev)
 {
struct drm_device *dev = pci_get_drvdata(pdev);
 
-   drm_put_dev(dev);
+   drm_put_pci_dev(dev);
 }
 
 static const struct file_operations cirrus_driver_fops = {
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 5320364..55eb824 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -388,6 +388,12 @@ err_g1:
 }
 EXPORT_SYMBOL(drm_get_pci_dev);
 
+void drm_put_pci_dev(struct drm_device *dev)
+{
+   drm_put_dev(dev);
+}
+EXPORT_SYMBOL(drm_put_pci_dev);
+
 /**
  * PCI device initialization. Called direct from modules at load time.
  *
@@ -460,7 +466,7 @@ void drm_pci_exit(struct drm_driver *driver, struct 
pci_driver *pdriver)
pci_unregister_driver(pdriver);
} else {
list_for_each_entry_safe(dev, tmp, &driver->device_list, 
driver_item)
-   drm_put_dev(dev);
+   drm_put_pci_dev(dev);
}
DRM_INFO("Module unloaded\n");
 }
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 0c47374..d7c3c9c 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -585,7 +585,7 @@ static void psb_driver_preclose(struct drm_device *dev, 
struct drm_file *priv)
 static void psb_remove(struct pci_dev *pdev)
 {
struct drm_device *dev = pci_get_drvdata(pdev);
-   drm_put_dev(dev);
+   drm_put_pci_dev(dev);
 }
 
 static const struct dev_pm_ops psb_pm_ops = {
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index a24ffbe..86ae5a2 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -856,7 +856,7 @@ i915_pci_remove(struct pci_dev *pdev)
 {
struct drm_device *dev = pci_get_drvdata(pdev);
 
-   drm_put_dev(dev);
+   drm_put_pci_dev(dev);
 }
 
 static int i915_pm_suspend(struct device *dev)
diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c 
b/drivers/gpu/drm/mgag200/mgag200_drv.c
index ea1024d..a3b0a4a 100644
--- a/drivers/gpu/drm/mgag200/mgag200_drv.c
+++ b/drivers/gpu/drm/mgag200/mgag200_drv.c
@@ -73,7 +73,7 @@ static void mga_pci_remove(struct pci_dev *pdev)
 {
struct drm_device *dev = pci_get_drvdata(pdev);
 
-   drm_put_dev(dev);
+   drm_put_pci_dev(dev);
 }
 
 static const struct file_operations mgag200_driver_fops = {
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.c 
b/drivers/gpu/drm/nouveau/nouveau_drv.c
index 9a36f5f..b74b02a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drv.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drv.c
@@ -168,7 +168,7 @@ nouveau_pci_remove(struct pci_dev *pdev)
 {
struct drm_device *dev = pci_get_drvdata(pdev);
 
-   drm_put_dev(dev);
+   drm_put_pci_dev(dev);
 }
 
 int
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c 
b/drivers/gpu/drm/radeon/radeon_drv.c
index 8c593ea..05d2ebc 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -310,7 +310,7 @@ radeon_pci_remove(struct pci_dev *pdev)
 {
struct drm_device *dev = pci_get_drvdata(pdev);
 
-   drm_put_dev(dev);
+   drm_put_pci_dev(dev);
 }
 
 static int
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 4d9edea..cf901cc 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -982,7 +982,7 @@ static void vmw_remove(struct pci_dev *pdev)
 {
struct drm_device *dev = pci_get_drvdata(pdev);
 
-   drm_put_dev(d

[PATCH 7/7] drm/pci: Defer initialization of secondary graphics devices until switcheroo is ready

2012-09-09 Thread Seth Forshee
Many Apple laptops with hybrid graphics require switching the i2c mux to
the integrated GPU when that device is being initialized in order to get
correct mode information for the LVDS panel. This requires that switcheroo
is ready at the time the device is initialized, which is not guaranteed.

To support this, delay calling the driver load() callback until the
vga_switcheroo handler and active client have been registered. This is
restricted to Apple notebooks via DMI data to avoid causing problems on
machines without switcheroo support.

Signed-off-by: Seth Forshee 
---
 drivers/gpu/drm/drm_drv.c |3 +
 drivers/gpu/drm/drm_pci.c |  164 -
 include/drm/drmP.h|2 +
 3 files changed, 153 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 9238de4..124fd8a 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -276,6 +276,8 @@ static int __init drm_core_init(void)
goto err_p3;
}
 
+   drm_pci_module_init();
+
DRM_INFO("Initialized %s %d.%d.%d %s\n",
 CORE_NAME, CORE_MAJOR, CORE_MINOR, CORE_PATCHLEVEL, CORE_DATE);
return 0;
@@ -291,6 +293,7 @@ err_p1:
 
 static void __exit drm_core_exit(void)
 {
+   drm_pci_module_exit();
remove_proc_entry("dri", NULL);
debugfs_remove(drm_debugfs_root);
drm_sysfs_destroy();
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 55eb824..a5c9068 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -40,6 +40,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include "drmP.h"
 
 /**/
@@ -297,19 +301,8 @@ static struct drm_bus drm_pci_bus = {
.agp_init = drm_pci_agp_init,
 };
 
-/**
- * Register.
- *
- * \param pdev - PCI device structure
- * \param ent entry from the PCI ID table with device type flags
- * \return zero on success or a negative number on failure.
- *
- * Attempt to gets inter module "drm" information. If we are first
- * then register the character device and inter module information.
- * Try and register, if we fail to register, backout previous work.
- */
-int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
-   struct drm_driver *driver)
+int __drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
+ struct drm_driver *driver)
 {
struct drm_device *dev;
int ret;
@@ -334,8 +327,6 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct 
pci_device_id *ent,
dev->hose = pdev->sysdata;
 #endif
 
-   mutex_lock(&drm_global_mutex);
-
if ((ret = drm_fill_in_dev(dev, ent, driver))) {
printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
goto err_g2;
@@ -371,7 +362,6 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct 
pci_device_id *ent,
 driver->name, driver->major, driver->minor, driver->patchlevel,
 driver->date, pci_name(pdev), dev->primary->index);
 
-   mutex_unlock(&drm_global_mutex);
return 0;
 
 err_g4:
@@ -386,10 +376,140 @@ err_g1:
mutex_unlock(&drm_global_mutex);
return ret;
 }
+
+/*
+ * List of machines that require delaying initialization of the secondary
+ * GPU until vga_switcheroo is ready.
+ */
+static struct dmi_system_id deferred_init_dmi_table[] = {
+   {
+   .ident = "Apple Laptop",
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+   DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */
+   },
+   },
+};
+
+struct deferred_init_data {
+   struct list_head list;
+   struct pci_dev *pdev;
+   const struct pci_device_id *ent;
+   struct drm_driver *driver;
+};
+
+static LIST_HEAD(deferred_init_list);
+
+static bool drm_pci_switcheroo_ready(void)
+{
+   if (!vga_switcheroo_handler_registered())
+   return false;
+   if (!vga_switcheroo_get_active_client())
+   return false;
+   return true;
+}
+
+static void drm_deferred_init_work_fn(struct work_struct *work)
+{
+   struct deferred_init_data *di_data, *temp;
+
+   mutex_lock(&drm_global_mutex);
+
+   if (!drm_pci_switcheroo_ready()) {
+   mutex_unlock(&drm_global_mutex);
+   return;
+   }
+
+   list_for_each_entry_safe(di_data, temp, &deferred_init_list, list) {
+   if (__drm_get_pci_dev(di_data->pdev, di_data->ent,
+ di_data->driver))
+   DRM_ERROR("pci device initialization failed\n");
+   list_del(&di_data->list);
+   kfree(di_data);
+   }
+   mutex_unlock(&drm_global_mutex);
+}
+static DECLARE_WORK(deferred_init_work, drm_deferred_init_work_fn);
+
+static i

Re: [PATCH 0/7] Fixes for hybrid graphics Apple machines

2012-09-09 Thread Seth Forshee
On Fri, Sep 07, 2012 at 10:35:04PM +0100, Dave Airlie wrote:
> On Fri, Sep 7, 2012 at 4:22 PM, Seth Forshee  
> wrote:
> > Many hybrid graphics Apple laptops fail to set up LVDS on the secondary
> > GPU due to missing or incorrect mode information for the panel at init
> > time. The only way to get the LVDS mode on these machines is via the
> > DDC, but this is muxed to the active GPU at boot. However, the graphics
> > mux on these machines supports muxing the i2c idependently of the
> > display, making it possible for the secondary graphics driver to read
> > the EDID without a full display switch.
> >
> > In order to support this, these patches modify vga_switcheroo to allow
> > muxing of the DDC idependently of the display. apple-gmux is updated to
> > support this new functionality, and drm_get_edid() is modified to switch
> > the DDC mux as needed.
> >
> > For this to work we also need to ensure that sufficient switcheroo
> > suport is available before initializing the secondary GPU. This is done
> > by adding any non-active GPUs that try to initialize before switcheroo
> > is ready to a list and initializing these devices once switcheroo
> > becomes ready. This behavior is restricted to Apple laptops to prevent
> > causing problems on other machines.
> 
> I hate this idea, no delaying stuff. We either need to have some sort
> of enforced ordering or make some stuff only work built-in.
> 
> But sticking things on a delayed list just in case seems wrong to me.

I really don't like it either. My preferred solution would be to have
i915 register the LVDS connector whenever we can reasonably expect that
an LVDS panel might be present, then treat the panel as disconnected
until we can get the mode information. I was headed down this path with
the first patches I sent, but both Daniel and Matthew responded
unfavorably to this approach.

Otherwise I'm open to suggestions on how enforcing the ordering of the
device initializations. Forcing apple-gmux to be built-in or making i915
depend on it might solve the problem, but I don't find either of these
to be very desirable either.

Thanks,
Seth

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: 3.5-rc7: nouveau doesn't X on NVC0

2012-09-09 Thread Alexey Dobriyan
On Thu, Sep 06, 2012 at 11:33:16AM +1000, Dave Airlie wrote:
> On Thu, Sep 6, 2012 at 11:15 AM, Linus Torvalds
>  wrote:
> > [ This got dropped somehow - it's in my draft folder. The bisection
> > may be irrelevant now: does it work with current git, since we've had
> > some nouveau changes? ]
> >
> > On Tue, Aug 28, 2012 at 8:26 AM, Alexey Dobriyan  
> > wrote:
> >> Ping!
> >>
> >> No X for me with 3.6-rc2.
> 
> Can you try -rc4?
> 
> Ben thinks the pcopy fix should fix it.

I've tried 3.6.0-rc5 and graphics works!
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel