comparison libvo/x11_common.c @ 10359:772571c63d45

move xv_set_eq to x11_common
author iive
date Tue, 01 Jul 2003 21:37:20 +0000
parents 87043624b0d8
children ccd39742b64c
comparison
equal deleted inserted replaced
10358:03f84d95397a 10359:772571c63d45
32 #endif 32 #endif
33 33
34 #ifdef HAVE_XF86VM 34 #ifdef HAVE_XF86VM
35 #include <X11/extensions/xf86vmode.h> 35 #include <X11/extensions/xf86vmode.h>
36 #include <X11/XF86keysym.h> 36 #include <X11/XF86keysym.h>
37 #endif
38
39 #ifdef HAVE_XV
40 #include <X11/extensions/Xv.h>
41 #include <X11/extensions/Xvlib.h>
37 #endif 42 #endif
38 43
39 #include "../input/input.h" 44 #include "../input/input.h"
40 #include "../input/mouse.h" 45 #include "../input/mouse.h"
41 46
1388 else if (!strcasecmp(name, "contrast")) *value = vo_contrast; 1393 else if (!strcasecmp(name, "contrast")) *value = vo_contrast;
1389 else if (!strcasecmp(name, "gamma")) *value = vo_gamma; 1394 else if (!strcasecmp(name, "gamma")) *value = vo_gamma;
1390 else return VO_NOTIMPL; 1395 else return VO_NOTIMPL;
1391 return VO_TRUE; 1396 return VO_TRUE;
1392 } 1397 }
1393 1398 #ifdef HAVE_XV
1394 1399 int vo_xv_set_eq(uint32_t xv_port, char *name, int value)
1400 {
1401 XvAttribute *attributes;
1402 int i,howmany, xv_atom;
1403
1404 mp_dbg(MSGT_VO, MSGL_V, "xv_set_eq called! (%s, %d)\n", name, value);
1405
1406 /* get available attributes */
1407 attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany);
1408 for (i = 0; i < howmany && attributes; i++)
1409 if (attributes[i].flags & XvSettable)
1410 {
1411 xv_atom = XInternAtom(mDisplay, attributes[i].name, True);
1412 /* since we have SET_DEFAULTS first in our list, we can check if it's available
1413 then trigger it if it's ok so that the other values are at default upon query */
1414 if (xv_atom != None)
1415 {
1416 int hue = 0,port_value,port_min,port_max;
1417
1418 if(!strcmp(attributes[i].name,"XV_BRIGHTNESS") &&
1419 (!strcasecmp(name, "brightness")))
1420 port_value = value;
1421 else
1422 if(!strcmp(attributes[i].name,"XV_CONTRAST") &&
1423 (!strcasecmp(name, "contrast")))
1424 port_value = value;
1425 else
1426 if(!strcmp(attributes[i].name,"XV_SATURATION") &&
1427 (!strcasecmp(name, "saturation")))
1428 port_value = value;
1429 else
1430 if(!strcmp(attributes[i].name,"XV_HUE") &&
1431 (!strcasecmp(name, "hue")))
1432 { port_value = value; hue=1; }
1433 else
1434 /* Note: since 22.01.2002 GATOS supports these attrs for radeons (NK) */
1435 if(!strcmp(attributes[i].name,"XV_RED_INTENSITY") &&
1436 (!strcasecmp(name, "red_intensity")))
1437 port_value = value;
1438 else
1439 if(!strcmp(attributes[i].name,"XV_GREEN_INTENSITY") &&
1440 (!strcasecmp(name, "green_intensity")))
1441 port_value = value;
1442 else
1443 if(!strcmp(attributes[i].name,"XV_BLUE_INTENSITY") &&
1444 (!strcasecmp(name, "blue_intensity")))
1445 port_value = value;
1446 else continue;
1447
1448 port_min = attributes[i].min_value;
1449 port_max = attributes[i].max_value;
1450
1451 /* nvidia hue workaround */
1452 if ( hue && port_min == 0 && port_max == 360 ){
1453 port_value = (port_value>=0) ? (port_value-100) : (port_value+100);
1454 }
1455
1456 // -100 -> min
1457 // 0 -> (max+min)/2
1458 // +100 -> max
1459 port_value = (port_value+100)*(port_max-port_min)/200+port_min;
1460 XvSetPortAttribute(mDisplay, xv_port, xv_atom, port_value);
1461 return(VO_TRUE);
1462 }
1463 }
1464 return(VO_FALSE);
1465 }
1466
1467 int vo_xv_get_eq(uint32_t xv_port, char *name, int *value)
1468 {
1469
1470 XvAttribute *attributes;
1471 int i,howmany, xv_atom;
1472
1473 /* get available attributes */
1474 attributes = XvQueryPortAttributes(mDisplay, xv_port, &howmany);
1475 for (i = 0; i < howmany && attributes; i++)
1476 if (attributes[i].flags & XvGettable)
1477 {
1478 xv_atom = XInternAtom(mDisplay, attributes[i].name, True);
1479 /* since we have SET_DEFAULTS first in our list, we can check if it's available
1480 then trigger it if it's ok so that the other values are at default upon query */
1481 if (xv_atom != None)
1482 {
1483 int val, port_value=0, port_min, port_max;
1484
1485 XvGetPortAttribute(mDisplay, xv_port, xv_atom, &port_value);
1486
1487 port_min = attributes[i].min_value;
1488 port_max = attributes[i].max_value;
1489 val=(port_value-port_min)*200/(port_max-port_min)-100;
1490
1491 if(!strcmp(attributes[i].name,"XV_BRIGHTNESS") &&
1492 (!strcasecmp(name, "brightness")))
1493 *value = val;
1494 else
1495 if(!strcmp(attributes[i].name,"XV_CONTRAST") &&
1496 (!strcasecmp(name, "contrast")))
1497 *value = val;
1498 else
1499 if(!strcmp(attributes[i].name,"XV_SATURATION") &&
1500 (!strcasecmp(name, "saturation")))
1501 *value = val;
1502 else
1503 if(!strcmp(attributes[i].name,"XV_HUE") &&
1504 (!strcasecmp(name, "hue"))){
1505 /* nasty nvidia detect */
1506 if (port_min == 0 && port_max == 360)
1507 *value = (val>=0) ? (val-100) : (val+100);
1508 else
1509 *value = val;
1510 } else
1511 /* Note: since 22.01.2002 GATOS supports these attrs for radeons (NK) */
1512 if(!strcmp(attributes[i].name,"XV_RED_INTENSITY") &&
1513 (!strcasecmp(name, "red_intensity")))
1514 *value = val;
1515 else
1516 if(!strcmp(attributes[i].name,"XV_GREEN_INTENSITY") &&
1517 (!strcasecmp(name, "green_intensity")))
1518 *value = val;
1519 else
1520 if(!strcmp(attributes[i].name,"XV_BLUE_INTENSITY") &&
1521 (!strcasecmp(name, "blue_intensity")))
1522 *value = val;
1523 else continue;
1524
1525 mp_dbg(MSGT_VO, MSGL_V, "xv_get_eq called! (%s, %d)\n", name, *value);
1526 return(VO_TRUE);
1527 }
1528 }
1529 return(VO_FALSE);
1530 }
1531
1532 #endif