Subversion Repositories HelenOS

Rev

Rev 4341 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4341 Rev 4342
Line 23... Line 23...
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
#include <ofw.h>
29
#include <ofw.h>
30
#include <ofwarch.h>
30
#include <ofwarch.h>
31
#include <printf.h>
31
#include <printf.h>
32
#include <asm.h>
32
#include <asm.h>
33
#include <types.h>
33
#include <types.h>
Line 370... Line 370...
370
        return false;
370
        return false;
371
   
371
   
372
    return true;
372
    return true;
373
}
373
}
374
 
374
 
-
 
375
#define RED(i)    (((i) >> 5) & ((1 << 3) - 1))
-
 
376
#define GREEN(i)  (((i) >> 3) & ((1 << 2) - 1))
-
 
377
#define BLUE(i)   ((i) & ((1 << 3) - 1))
-
 
378
#define CLIP(i)   ((i) <= 255 ? (i) : 255)
-
 
379
 
-
 
380
 
375
/**
381
/**
376
 * Sets up the palette for the 8-bit color depth configuration so that the
382
 * Sets up the palette for the 8-bit color depth configuration so that the
377
 * 3:2:3 color scheme can be used. Checks that setting the palette makes sense
383
 * 3:2:3 color scheme can be used. Checks that setting the palette makes sense
378
 * (appropriate nodes exist in the OBP tree and the color depth is not greater
384
 * (appropriate nodes exist in the OBP tree and the color depth is not greater
379
 * than 8).
385
 * than 8).
-
 
386
 *
-
 
387
 * @return true if the palette has been set, false otherwise
380
 *
388
 *
381
 * @return  true if the palette has been set, false otherwise
-
 
382
 */
389
 */
383
int setup_palette(void)
390
int ofw_setup_palette(void)
384
{
391
{
385
    char device_name[BUF_SIZE];
392
    char device_name[BUF_SIZE];
386
   
393
   
387
    /* resolve alias */
394
    /* resolve alias */
388
    if (ofw_get_property(ofw_aliases, "screen", device_name,
395
    if (ofw_get_property(ofw_aliases, "screen", device_name,
389
        sizeof(device_name)) <= 0)
396
        sizeof(device_name)) <= 0)
390
        return false;
397
        return false;
391
 
398
   
392
    /* for depth greater than 8 it makes no sense to set up the palette */
399
    /* for depth greater than 8 it makes no sense to set up the palette */
393
    uint32_t depth;
400
    uint32_t depth;
394
    phandle device = ofw_find_device(device_name);
401
    phandle device = ofw_find_device(device_name);
395
    if (device == -1)
402
    if (device == -1)
396
        return false;
403
        return false;
Line 401... Line 408...
401
   
408
   
402
    /* required in order to be able to make a method call */
409
    /* required in order to be able to make a method call */
403
    ihandle screen = ofw_open(device_name);
410
    ihandle screen = ofw_open(device_name);
404
    if (screen == -1)
411
    if (screen == -1)
405
        return false;
412
        return false;
406
 
413
   
407
    /* setup the palette so that the (inverted) 3:2:3 scheme is usable */
414
    /* setup the palette so that the (inverted) 3:2:3 scheme is usable */
408
    unsigned int i;
415
    unsigned int i;
409
    for (i = 0; i < 256; i++)
416
    for (i = 0; i < 256; i++)
410
        if (ofw_call("call-method", 6, 1, NULL, "color!", screen,
417
        ofw_call("call-method", 6, 1, NULL, "color!", screen,
411
            255 - i,
-
 
412
            i << 5,
-
 
413
            (i >> 3) << 6,
-
 
414
            (i >> 5) << 5) != 0);
418
            255 - i, CLIP(BLUE(i) * 37), GREEN(i) * 85, CLIP(RED(i) * 37));
415
    return true;
419
    return true;
416
}
420
}
417
 
421
 
418
void ofw_quiesce(void)
422
void ofw_quiesce(void)
419
{
423
{