From 2c4b27b9d3934e845e035a4b851bfe3ba6093828 Mon Sep 17 00:00:00 2001 From: linuxlite Date: Sat, 9 Aug 2014 08:58:11 +0200 Subject: [PATCH] use hdparm to set speedcontrol. --- packages/sysutils/busybox/package.mk | 2 +- packages/sysutils/speedcontrol/package.mk | 42 ------ .../speedcontrol/sources/speedcontrol.c | 136 ------------------ .../hdparm}/udev.d/61-cdrom.rules | 2 +- 4 files changed, 2 insertions(+), 180 deletions(-) delete mode 100644 packages/sysutils/speedcontrol/package.mk delete mode 100644 packages/sysutils/speedcontrol/sources/speedcontrol.c rename packages/{sysutils/speedcontrol => tools/hdparm}/udev.d/61-cdrom.rules (94%) diff --git a/packages/sysutils/busybox/package.mk b/packages/sysutils/busybox/package.mk index d50abb1bb9..1918f05156 100644 --- a/packages/sysutils/busybox/package.mk +++ b/packages/sysutils/busybox/package.mk @@ -24,7 +24,7 @@ PKG_LICENSE="GPL" PKG_SITE="http://www.busybox.net" PKG_URL="http://busybox.net/downloads/$PKG_NAME-$PKG_VERSION.tar.bz2" PKG_DEPENDS_HOST="" -PKG_DEPENDS_TARGET="toolchain busybox:host hdparm dosfstools e2fsprogs speedcontrol zip unzip pciutils usbutils parted" +PKG_DEPENDS_TARGET="toolchain busybox:host hdparm dosfstools e2fsprogs zip unzip pciutils usbutils parted" PKG_DEPENDS_INIT="toolchain" PKG_PRIORITY="required" PKG_SECTION="system" diff --git a/packages/sysutils/speedcontrol/package.mk b/packages/sysutils/speedcontrol/package.mk deleted file mode 100644 index aeedcaeb94..0000000000 --- a/packages/sysutils/speedcontrol/package.mk +++ /dev/null @@ -1,42 +0,0 @@ -################################################################################ -# This file is part of OpenELEC - http://www.openelec.tv -# Copyright (C) 2009-2014 Stephan Raue (stephan@openelec.tv) -# -# OpenELEC is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# OpenELEC 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 OpenELEC. If not, see . -################################################################################ - -PKG_NAME="speedcontrol" -PKG_VERSION="1" -PKG_REV="1" -PKG_ARCH="any" -PKG_LICENSE="GPL" -PKG_SITE="http://noto.de" -PKG_URL="" -PKG_DEPENDS_TARGET="toolchain" -PKG_PRIORITY="optional" -PKG_SECTION="system" -PKG_SHORTDESC="speedcontrol: a tool to setup cdrom drive speed" -PKG_LONGDESC="speedcontrol is a tool to setup cdrom drive speed" - -PKG_IS_ADDON="no" -PKG_AUTORECONF="no" - -make_target() { - $CC $CFLAGS $LDFLAGS -o $PKG_NAME $PKG_NAME.c -} - -makeinstall_target() { - mkdir -p $INSTALL/usr/bin - cp $PKG_NAME $INSTALL/usr/bin -} diff --git a/packages/sysutils/speedcontrol/sources/speedcontrol.c b/packages/sysutils/speedcontrol/sources/speedcontrol.c deleted file mode 100644 index 74cef2fc7a..0000000000 --- a/packages/sysutils/speedcontrol/sources/speedcontrol.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * SpeedControl - use SET STREAMING command to set the speed of DVD-drives - * - * - * Copyright (c) 2004 Thomas Fritzsche - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110, USA. - * - */ - -#include -#include -#include -#include -#include -#include -#include - - -void dump_sense(unsigned char *cdb, struct request_sense *sense) -{ - int i; - - printf("Command failed: "); - - for (i=0; i<12; i++) - printf("%02x ", cdb[i]); - - if (sense) { - printf(" - sense: %02x.%02x.%02x\n", sense->sense_key, sense->asc, - sense->ascq); - } else { - printf(", no sense\n"); - } -} - -int main(int argc, char *argv[]) -{ - char *device = "/dev/cdrom"; - int c,fd; - int speed = 0; - unsigned long rw_size; - - unsigned char buffer[28]; - - struct cdrom_generic_command cgc; - struct request_sense sense; - extern char * optarg; - - while((c=getopt(argc,argv,"x:"))!=EOF) { - switch(c) { - case 'x': speed = atoi(optarg); break; - default: - printf("Usage: speedcontrol [-x speed] [device]"); - return -1; - } - } - - if (argc > optind) device = argv[optind]; - - fd = open(device, O_RDONLY | O_NONBLOCK); - if (fd < 0) { - printf("Can't open device %s\n", device); - return -1; - } - - - memset(&cgc, 0, sizeof(cgc)); - memset(&sense, 0, sizeof(sense)); - memset(&buffer, 0, sizeof(buffer)); - - /* SET STREAMING command */ - cgc.cmd[0] = 0xb6; - /* 28 byte parameter list length */ - cgc.cmd[10] = 28; - - cgc.sense = &sense; - cgc.buffer = buffer; - cgc.buflen = sizeof(buffer); - cgc.data_direction = CGC_DATA_WRITE; - cgc.quiet = 1; - - if(speed == 0) { -/* set Restore Drive Defaults */ - buffer[0] = 4; - } - - buffer[8] = 0xff; - buffer[9] = 0xff; - buffer[10] = 0xff; - buffer[11] = 0xff; - - rw_size = 177 * speed; - -/* read size */ - buffer[12] = (rw_size >> 24) & 0xff; - buffer[13] = (rw_size >> 16) & 0xff; - buffer[14] = (rw_size >> 8) & 0xff; - buffer[15] = rw_size & 0xff; - -/* read time 1 sec. */ - buffer[18] = 0x03; - buffer[19] = 0xE8; - -/* write size */ - buffer[20] = (rw_size >> 24) & 0xff; - buffer[21] = (rw_size >> 16) & 0xff; - buffer[22] = (rw_size >> 8) & 0xff; - buffer[23] = rw_size & 0xff; - -/* write time 1 sec. */ - buffer[26] = 0x03; - buffer[27] = 0xE8; - - if (ioctl(fd, CDROM_SEND_PACKET, &cgc) != 0) - if (ioctl(fd, CDROM_SELECT_SPEED, speed) != 0) { - dump_sense(cgc.cmd, cgc.sense); - printf("ERROR.\n"); - return -1; - } - printf("OK...\n"); - return 0; -} - diff --git a/packages/sysutils/speedcontrol/udev.d/61-cdrom.rules b/packages/tools/hdparm/udev.d/61-cdrom.rules similarity index 94% rename from packages/sysutils/speedcontrol/udev.d/61-cdrom.rules rename to packages/tools/hdparm/udev.d/61-cdrom.rules index 2181406e55..2979ba4fd2 100644 --- a/packages/sysutils/speedcontrol/udev.d/61-cdrom.rules +++ b/packages/tools/hdparm/udev.d/61-cdrom.rules @@ -20,6 +20,6 @@ ACTION!="add|change", GOTO="cdrom_end" # set CDROM speed -KERNEL=="sr*", RUN+="/usr/bin/speedcontrol -x8 /dev/%k" +KERNEL=="sr*", RUN+="/sbin/hdparm -E8 /dev/%k" LABEL="cdrom_end"