Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright 2007, 2008  Luc Verhaegen <lverhaegen@novell.com>
  3.  * Copyright 2007, 2008  Matthias Hopf <mhopf@novell.com>
  4.  * Copyright 2007, 2008  Egbert Eich   <eich@novell.com>
  5.  * Copyright 2007, 2008  Advanced Micro Devices, Inc.
  6.  *
  7.  * Permission is hereby granted, free of charge, to any person obtaining a
  8.  * copy of this software and associated documentation files (the "Software"),
  9.  * to deal in the Software without restriction, including without limitation
  10.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11.  * and/or sell copies of the Software, and to permit persons to whom the
  12.  * Software is furnished to do so, subject to the following conditions:
  13.  *
  14.  * The above copyright notice and this permission notice shall be included in
  15.  * all copies or substantial portions of the Software.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  20.  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  21.  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  22.  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  23.  * OTHER DEALINGS IN THE SOFTWARE.
  24.  */
  25.  
  26. #ifdef HAVE_CONFIG_H
  27. #include "config.h"
  28. #endif
  29.  
  30. #include "xf86.h"
  31.  
  32. #include "rhd.h"
  33. #include "rhd_connector.h"
  34. #include "rhd_output.h"
  35. #include "rhd_crtc.h"
  36.  
  37. char *rhdPowerString[] = {
  38.     "POWER_ON",
  39.     "POWER_RESET",
  40.     "POWER_SHUTDOWN",
  41.     "POWER_UNKNOWN"
  42. };
  43.  
  44. void
  45. RHDOutputAdd(RHDPtr rhdPtr, struct rhdOutput *New)
  46. {
  47.   struct rhdOutput *Last = rhdPtr->Outputs;
  48.  
  49.   RHDFUNC(rhdPtr);
  50.  
  51.   if (!New)
  52.     return;
  53.  
  54.     if (Last) {
  55.     while (Last->Next)
  56.             Last = Last->Next;
  57.  
  58.     Last->Next = New;
  59.   } else
  60.         rhdPtr->Outputs = New;
  61. }
  62.  
  63. /*
  64.  *
  65.  */
  66. void
  67. RHDOutputsMode(RHDPtr rhdPtr, struct rhdCrtc *Crtc, DisplayModePtr Mode)
  68. {
  69.     struct rhdOutput *Output = rhdPtr->Outputs;
  70.  
  71.     RHDFUNC(rhdPtr);
  72.  
  73.     while (Output) {
  74.         if (Output->Active && Output->Mode && (Output->Crtc == Crtc))
  75.             Output->Mode(Output, Mode);
  76.  
  77.         Output = Output->Next;
  78.     }
  79. }
  80.  
  81. /*
  82.  *
  83.  */
  84. void
  85. RHDOutputsPower(RHDPtr rhdPtr, int Power)
  86. {
  87.     struct rhdOutput *Output = rhdPtr->Outputs;
  88.  
  89.     RHDFUNC(rhdPtr);
  90.  
  91.     while (Output) {
  92.         if (Output->Active && Output->Power)
  93.             Output->Power(Output, Power);
  94.  
  95.         Output = Output->Next;
  96.     }
  97. }
  98.  
  99. /*
  100.  *
  101.  */
  102. void
  103. RHDOutputsShutdownInactive(RHDPtr rhdPtr)
  104. {
  105.   struct rhdOutput *Output = rhdPtr->Outputs;
  106.  
  107.   RHDFUNC(rhdPtr);
  108.  
  109.     while (Output) {
  110.         if (!Output->Active && Output->Power) {
  111.             xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Shutting down %s\n", Output->Name);
  112.       Output->Power(Output, RHD_POWER_SHUTDOWN);
  113.     }
  114.  
  115.     Output = Output->Next;
  116.   }
  117. }
  118.  
  119. /*
  120.  *
  121.  */
  122. void
  123. RHDOutputsSave(RHDPtr rhdPtr)
  124. {
  125.     struct rhdOutput *Output = rhdPtr->Outputs;
  126.  
  127.     RHDFUNC(rhdPtr);
  128.  
  129.     while (Output) {
  130.         if (Output->Save)
  131.             Output->Save(Output);
  132.  
  133.         Output = Output->Next;
  134.     }
  135. }
  136.  
  137. /*
  138.  *
  139.  */
  140. void
  141. RHDOutputsRestore(RHDPtr rhdPtr)
  142. {
  143.     struct rhdOutput *Output = rhdPtr->Outputs;
  144.  
  145.     RHDFUNC(rhdPtr);
  146.  
  147.     while (Output) {
  148.         if (Output->Restore)
  149.             Output->Restore(Output);
  150.  
  151.         Output = Output->Next;
  152.     }
  153. }
  154.  
  155. /*
  156.  *
  157.  */
  158. void
  159. RHDOutputsDestroy(RHDPtr rhdPtr)
  160. {
  161.     struct rhdOutput *Output = rhdPtr->Outputs, *Next;
  162.  
  163.     RHDFUNC(rhdPtr);
  164.  
  165.     while (Output) {
  166.         Next = Output->Next;
  167.  
  168.         xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Destroying %s\n", Output->Name);
  169.  
  170.         if (Output->Destroy)
  171.             Output->Destroy(Output);
  172.  
  173.         if (Output->OutputDriverPrivate)
  174.             xfree(Output->OutputDriverPrivate);
  175.         xfree(Output);
  176.  
  177.         Output = Next;
  178.     }
  179. }
  180.  
  181. /*
  182.  *
  183.  */
  184. void
  185. RHDOutputPrintSensedType(struct rhdOutput *Output)
  186. {
  187.     struct { enum rhdSensedOutput type; char *name; }
  188.     list[] = { { RHD_SENSED_NONE, "none" },
  189.              { RHD_SENSED_VGA, "VGA" },
  190.              { RHD_SENSED_DVI, "DVI" },
  191.              { RHD_SENSED_TV_SVIDEO, "TV_SVIDEO"},
  192.              { RHD_SENSED_TV_COMPOSITE, "TV_COMPOSITE" },
  193.              { RHD_SENSED_TV_COMPONENT, "TV_COMPONENT" },
  194.              { 0, NULL }
  195.     };
  196.     int i = 0;
  197.  
  198.     while (list[i].name) {
  199.         if (list[i].type == Output->SensedType) {
  200.             xf86DrvMsgVerb(Output->scrnIndex, X_INFO, 3,
  201.                            "%s: Sensed Output: %s\n",Output->Name,
  202.                            list[i].name);
  203.             return;
  204.         }
  205.         i++;
  206.     }
  207. }
  208.